Published on

flutter3.x 中文字体显示混乱问题

Authors

按照flutter官方文档,添加多语言支持。

class MainApp extends StatelessWidget {
  const MainApp({super.key});

  
  Widget build(BuildContext context) {
    return MaterialApp(
      localizationsDelegates: const [
        GlobalMaterialLocalizations.delegate,
        GlobalCupertinoLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate
      ],
      themeMode: ThemeMode.system,
      theme: ThemeData(
          colorScheme: ColorScheme.fromSeed(seedColor: Colors.indigo),
          useMaterial3: true,
          brightness: Brightness.light),
      darkTheme: ThemeData(
          colorSchemeSeed: Colors.blue,
          useMaterial3: true,
          brightness: Brightness.dark),
      supportedLocales: const [Locale("zh", "CN"), Locale("en", "US")],
      home: const HomePage(),
    );
  }
}

https://github.com/flutter/flutter/issues/103811#issuecomment-1199012026 https://github.com/flutter/flutter/issues/103811#issuecomment-1199059077 解决办法,引入本地化设置。