1. 安装依赖

    在pubspec.yaml文件中插入

    1. dependencies:
    2. flutter_localizations:
    3. sdk: flutter
    1. 在MeteralApp组件中配置
    1. MaterialApp(
    2. localizationsDelegates: [
    3. GlobalMaterialLocalizations.delegate,
    4. GlobalWidgetsLocalizations.delegate,
    5. ],
    6. supportedLocales: [
    7. const Locale('zh', 'CN'),
    8. const Locale('en', 'US'),
    9. ],
    10. title: 'xxx',
    11. theme: myTheme(),
    12. home: Home({}),
    13. );
    14. }