flutter_device_preview
flutter_device_preview copied to clipboard
DevicePreview.locale isn't working with GetMaterialApp
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.
any updates ?
same issue
same issue , any updates ?
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.
I use the device_preview: ^1.1.0 it works for me. let's try it