Hệ thống theming của Flutter cho phép bạn định nghĩa styling trực quan nhất quán (màu sắc, font, style component) trên toàn ứng dụng, với hỗ trợ theme sáng/tối. Tập trung hóa styling qua theme đảm bảo tính nhất quán và làm cho ứng dụng dễ đổi style.
Định nghĩa một theme
// định nghĩa theme của ứng dụng trong MaterialApp
MaterialApp(
theme: ThemeData( // theme SÁNG
colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue),
textTheme: TextTheme(/* style font */),
elevatedButtonTheme: /* style button */,
useMaterial3: true,
),
darkTheme: ThemeData.dark(), // theme TỐI
themeMode: ThemeMode.system, // theo cài đặt hệ thống (hoặc .light/.dark)
)
