-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSettings.dart
87 lines (77 loc) · 2.54 KB
/
Settings.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
bool switche = false ;
ThemeData light = ThemeData(brightness: Brightness.light,);
ThemeData dark = ThemeData(brightness: Brightness.dark,);
String a = 'English';
class Settings extends StatefulWidget{
@override
_SettingsState createState() => _SettingsState();
}
class _SettingsState extends State<Settings> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Settings',style: TextStyle(fontSize: 20.0),),
),
body:Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Text('Dark or Light',style: TextStyle(fontSize: 20),),
SizedBox(width: 10,),
Switch(value: switche, onChanged:(bool value) {
setState(() {
switche = value ;
});
})
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Text('Change Languge',style: TextStyle(fontSize: 20.0),),
SizedBox(width: 10,),
Container(
child: DropdownButton(
iconSize: 30.0,
value: a,
onChanged: (String b){
setState(() {
a=b;
});
},
items:<String> ['English','Spanish'].map((e) => DropdownMenuItem(
value: e,
onTap: () {
},
child: Text(e))).toList(), ),
),
],
)
],
),
);
}
}
class ChangeThemeButum extends StatelessWidget{
@override
Widget build(BuildContext context) {
final themeProvider = Provider.of<ThemeProvider>(context);
return Switch.adaptive(value: themeProvider.isDarkmode,
onChanged:(value) {
final provider= Provider.of<ThemeProvider>(context,listen: false);
provider.togglTheme(value);
});
}
} class ThemeProvider extends ChangeNotifier{
ThemeMode _themeMode = ThemeMode.dark;
bool get isDarkmode => _themeMode==ThemeMode.dark;
void togglTheme(bool isOn){
_themeMode = isOn ? ThemeMode.dark : ThemeMode.light;
notifyListeners();
}
}