@@ -17,66 +17,20 @@ void main() {
17
17
runApp (MyApp ());
18
18
}
19
19
20
- class MyApp extends StatefulWidget {
21
- @override
22
- _MyAppState createState () => _MyAppState ();
23
- }
24
-
25
- class _MyAppState extends State <MyApp > {
26
- UniqueKey key1 = UniqueKey ();
27
- UniqueKey key2 = UniqueKey ();
28
- GlobalKey <NavigatorState > navigatorKey = GlobalKey <NavigatorState >();
20
+ class MyApp extends StatelessWidget {
29
21
@override
30
22
Widget build (BuildContext context) {
31
- return Container (
32
- key: key1,
33
- child: BotToastInit (
34
- child: MaterialApp (
35
- key: key2,
36
- title: 'BotToast Demo' ,
37
- navigatorKey: navigatorKey,
38
- navigatorObservers: [BotToastNavigatorObserver ()],
39
- home: Column (
40
- children: < Widget > [
41
- RaisedButton (
42
- onPressed: () async {
43
- setState (() {
44
- key1 = UniqueKey ();
45
- });
46
- },
47
- child: Text ('切换外层key' ),
48
- ),
49
- RaisedButton (
50
- onPressed: () async {
51
- setState (() {
52
- key2 = UniqueKey ();
53
- });
54
- },
55
- child: Text ('切换内层层key' ),
56
- ),
57
- RaisedButton (
58
- onPressed: () async {
59
- setState (() {
60
- navigatorKey = GlobalKey <NavigatorState >();
61
- });
62
- },
63
- child: Text ('切换导航key' ),
64
- ),
65
- Expanded (child: EnterPage ()),
66
- ],
67
- ),
68
- ),
23
+ return BotToastInit (
24
+ child: MaterialApp (
25
+ title: 'BotToast Demo' ,
26
+ navigatorObservers: [BotToastNavigatorObserver ()],
27
+ home: EnterPage (),
69
28
),
70
29
);
71
30
}
72
31
}
73
32
74
- class EnterPage extends StatefulWidget {
75
- @override
76
- _EnterPageState createState () => _EnterPageState ();
77
- }
78
-
79
- class _EnterPageState extends State <EnterPage > {
33
+ class EnterPage extends StatelessWidget {
80
34
@override
81
35
Widget build (BuildContext context) {
82
36
return Scaffold (
@@ -88,33 +42,13 @@ class _EnterPageState extends State<EnterPage> {
88
42
alignment: Alignment .topCenter,
89
43
child: SingleChildScrollView (
90
44
child: Container (
91
- margin: EdgeInsets .only (top: 5 ),
45
+ margin: EdgeInsets .only (top: 30 ),
92
46
child: Column (children: < Widget > [
93
47
Text (
94
48
"Notification" ,
95
49
style: TextStyle (fontWeight: FontWeight .w500, fontSize: 20 ),
96
50
),
97
51
Divider (),
98
- RaisedButton (
99
- onPressed: () async {
100
- final cancel = BotToast .showText (
101
- text: 'test' , duration: null );
102
- // await Future.delayed(Duration(milliseconds: 500));
103
- // cancel();
104
- },
105
- child: Text ('test' ),
106
- ),
107
- RaisedButton (
108
- onPressed: () async {
109
- // NavigatorState n=Navigator.of(context);
110
- // n.popUntil((_)=>false);
111
-
112
- Navigator .of (context).pushAndRemoveUntil (
113
- MaterialPageRoute (builder: (_) => EnterPage ()), (
114
- _) => false );
115
- },
116
- child: Text ('弹出所有路由再push' ),
117
- ),
118
52
Row (
119
53
children: < Widget > [
120
54
Expanded (
0 commit comments