How to localise CupertinoDatePicker in flutter and getxcontroller

Issue

During my search I found some regular solution when no GetXcontroller included, like this https://stackoverflow.com/a/53752290/19815795

Taking above as inspiration, I created some code for my GetMaterialApp:

GetMaterialApp(
        theme: AppTheme(),
        translations: Language(),
        locale: getCurrentLocale(),
        fallbackLocale: Locale('en', 'US'),
        supportedLocales: [ // Here I got error, maybe because I am using GetXController
        const Locale('en', 'US'),
        const Locale('de', 'DE'),
        const Locale('fr', 'FR'),
        const Locale('zh', 'CN'),
        const Locale('ar', 'QA'),
        const Locale('es', 'ES'),
          ],
        debugShowCheckedModeBanner: false,
        localizationsDelegates: [
          DefaultCupertinoLocalizationsLocal.delegate, // code from above link
        ],

        home: SettingScreen(),
        );

But as result, the CupertinoPicker didn’t recognise my local language, still using default english, does anyone know how to localise CupertinoDatePicker in flutter and getxcontroller, thanks!

Solution

Try adding those to localizationsDelegates:

  GlobalMaterialLocalizations.delegate,
  GlobalWidgetsLocalizations.delegate,
  DefaultCupertinoLocalizations.delegate,

Answered By – Gwhyyy

Answer Checked By – Candace Johnson (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *