Sistem theming Flutter membolehkan anda mentakrifkan styling visual yang konsisten (warna, fon, gaya komponen) merentas seluruh aplikasi, dengan sokongan untuk tema terang/gelap. Memusatkan styling melalui tema memastikan konsistensi dan menjadikan aplikasi mudah untuk distail semula.
Mentakrifkan tema
// define the app's theme in MaterialApp
MaterialApp(
theme: ThemeData( // LIGHT theme
colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue),
textTheme: TextTheme(/* font styles */),
elevatedButtonTheme: /* button styling */,
useMaterial3: true,
),
darkTheme: ThemeData.dark(), // DARK theme
themeMode: ThemeMode.system, // follow the system setting (or .light/.dark)
)
