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

make DevicePreview and GetMaterialApp.router can work together on locale changes #2656

Open
jackliusr opened this issue Jan 3, 2023 · 2 comments

Comments

@jackliusr
Copy link

ATTENTION: DO NOT USE THIS FIELD TO ASK SUPPORT QUESTIONS. USE THE PLATFORM CHANNELS FOR THIS. THIS SPACE IS DEDICATED ONLY FOR FEATURE REQUESTS

Is your feature request related to a problem? Please describe.
I use GetMaterialApp.router in my project and use DevicePreview to test layout issues. However one thing is quite annoying that locale changes don't trigger the UI change.

Describe the solution you'd like
locale changes in device preview will trigger locale change in GetMaterialApp.router.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

@Obada2020
Copy link

any updates

@jessicamrbr
Copy link

Apparently this worked for me:

// ...
  runApp(
    DevicePreview(
      availableLocales: const [
        Locale('en', 'US'),
        Locale('pt', 'BR'),
        // ...
      ],
      enabled: !kReleaseMode,
      builder: (context) => GetMaterialApp(
        builder: (BuildContext ctx, Widget? widget) {
          // ...
          DevicePreview.appBuilder(ctx, widget),
          // ...
        },
        translations: value_sets.AppLabels(),
        locale: () {
          if(!kReleaseMode) {
            Get.locale = DevicePreview.locale(context);
            return DevicePreview.locale(context);
          }
          return Get.deviceLocale;
        }(),
        fallbackLocale: const Locale('pt', 'BR'),
        // ...
      ),
    ),
  );
// ...

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

3 participants