Flutter 去掉右上角Debug式样
去掉 右上角Debug Banner
MaterialApp(
debugShowCheckedModeBanner: false,
)
系统设置为深色模式时,应用也做相应的深色模式
MaterialApp(
darkTheme: ThemeData(brightness: Brightness.dark),
)
Locale一种标识符,用于选择用户的语言和格式化偏好
//fr法语,CH瑞士
static const Locale swissFrench = Locale('fr', 'CH');
MaterialApp(
locale: swissFrench,
)
themeMode:确定应用程序将使用哪个主题,如果theme和darkTheme都被提供
MaterialApp(
darkTheme: ThemeData(brightness: Brightness.dark),
themeMode: ThemeMode.dark,
theme: ThemeData(
primarySwatch: Colors.green,
visualDensity: VisualDensity.adaptivePlatformDensity),
)
如果darkTheme 为null,则它将退回到使用theme
themeMode 的三种模式:
///Use either the light or dark theme based on what the user has selected in
/// the system settings
system,
/// Always use the light mode regardless of system preference.
light,
/// Always use the dark mode (if available) regardless of system preference.
dark,