comm_app 0.0.1-dev copy "comm_app: ^0.0.1-dev" to clipboard
comm_app: ^0.0.1-dev copied to clipboard

flutter app encapsulates basic app functions.

flutter app encapsulates basic app functions #

1、LanguageUtils language switching function #

1、Initialize language list
  void main() async {

  /// Initialize utils
  await XUtils.get.init(debug: kDebugMode);
  
  ///SpUtils is used, so you need to initialize xutils first
  var languageList = <LanguageVo>[];
  languageList.add(LanguageVo(Language.en.name, Language.en.languageCode, Language.en.countryCode));
  languageList.add(LanguageVo(Language.cn.name, Language.cn.languageCode, Language.cn.countryCode));
  languageList.add(LanguageVo(Language.tw.name, Language.tw.languageCode, Language.tw.countryCode));
  LanguageUtils.get.init(languageList, (locale) => S.load(locale));
  
  runApp(const MyApp());
}

2、Internationalization: configure the current language
  GetMaterialApp(
      localizationsDelegates: const [
        S.delegate,
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
        GlobalCupertinoLocalizations.delegate,
      ],
      locale: LanguageUtils.get.getCurrentLocal(),
      supportedLocales: S.delegate.supportedLocales,
      ...
    );

3、switch language
   LanguageUtils.get.changeLanguage(value, (locale) => S.load(locale));
  ///Re render page
   setState(() {});
0
likes
130
pub points
0%
popularity

Publisher

unverified uploader

flutter app encapsulates basic app functions.

Homepage

Documentation

API reference

License

Apache-2.0 (LICENSE)

Dependencies

comm_utils, flutter, json_annotation

More

Packages that depend on comm_app