ระบบ theming ของ Flutter ช่วยให้คุณกำหนด styling ที่สม่ำเสมอ (สี, ฟอนต์, สไตล์ของ component) ทั่วทั้งแอป พร้อมรองรับ light/dark themes การรวมศูนย์ styling ผ่าน themes ช่วยให้เกิดความสม่ำเสมอและทำให้แอปปรับสไตล์ได้ง่าย
การกำหนด theme
// 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)
)
