第一步 引入依赖

dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter

第二步 在main.dart中添加代码

 MaterialApp(
   //省略若干代码........
  //国际化
  localizationsDelegates: [
    GlobalMaterialLocalizations.delegate,
    GlobalWidgetsLocalizations.delegate,
    GlobalCupertinoLocalizations.delegate,
  ],
  supportedLocales: [
    const Locale('zh', 'CN'),
    const Locale('en', 'US'),
  ],
)

第三步 重启app

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-28
  • 2022-02-07
  • 2022-12-23
  • 2021-08-04
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-11
  • 2021-08-28
  • 2022-02-08
  • 2021-09-18
  • 2021-08-11
相关资源
相似解决方案