-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdark-mode.dart
40 lines (34 loc) · 1.13 KB
/
dark-mode.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
final Brightness brightnessValue =
MediaQuery.of(context).platformBrightness;
bool isDark = brightnessValue == Brightness.dark;
//set the color to -
color: Theme.of(context).textTheme.bodyText1!.color
//checking if the system is in dark mode or light mode -
Image.asset(
MediaQuery.of(context).platformBrightness == Brightness.light
? "assets/lightmode2.png"
:"assets/darkmode.png",
height: 256,
)
//Check system mode -
Widget build(BuildContext context) {
final Brightness brightnessValue = MediaQuery.of(context).platformBrightness;
bool isDark = brightnessValue == Brightness.dark;
. . . . .
. . . . .
. . . . .
Text(
'Choose your theme',
style: isDark == true ? TextStyle(
color: Colors.black,
fontSize: 16,
letterSpacing: 4,
fontWeight: FontWeight.w500
):
TextStyle(
color: Colors.white,
fontSize: 16,
letterSpacing: 4,
fontWeight: FontWeight.w500
),
),