Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DevicePreview.locale isn't working with GetMaterialApp #219

Open
divan opened this issue Feb 16, 2023 · 5 comments
Open

DevicePreview.locale isn't working with GetMaterialApp #219

divan opened this issue Feb 16, 2023 · 5 comments

Comments

@divan
Copy link

divan commented Feb 16, 2023

Hey, it seems like locale setting doesn't work with GetMaterialApp from GetX. It supposed to be a wrapper around MaterialApp so should work transparently, but it messes up with some internals so switching locale in DevicePreview doesn't work.

  runApp(
    DevicePreview(
      enabled: !kReleaseMode,
      builder: (context) => const App(), // Wrap your app
      availableLocales: const [
        Locale('en'),
        Locale('uk'),
      ],
    ),
  );
class App extends StatelessWidget {
  const App({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GetMaterialApp(
      title: 'My App',
      localizationsDelegates: const [
        AppLocalizations.delegate,
        GlobalMaterialLocalizations.delegate,
        GlobalCupertinoLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
      ],
      supportedLocales: const [
        Locale('en'),
        Locale('uk'),
      ],
      debugShowCheckedModeBanner: false,
      useInheritedMediaQuery: true,
      locale: DevicePreview.locale(context), // not working
      builder: DevicePreview.appBuilder,
      home: MainApp(),
    );
  }
}

Any ideas how to solve this issue?

PS. There is a issue in GetX for that, but not sure it has got any attention.

@Obada2020
Copy link

any updates ?

@FakharAlyas119
Copy link

same issue

@MostafaElswefy
Copy link

same issue , any updates ?

@AbdalazizAbdallah
Copy link

AbdalazizAbdallah commented Apr 1, 2023

i faced this problem and solved , there was confliction between packages maybe device preview not latest version and there was conflict with intl in my case , just i solved by downgrading for intl.

@vignesh235
Copy link

I use the device_preview: ^1.1.0 it works for me. let's try it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants