Skip to content

Commit 8b0cb15

Browse files
committed
update example
1 parent 89e05c0 commit 8b0cb15

File tree

2 files changed

+9
-74
lines changed

2 files changed

+9
-74
lines changed

example/android/gradle.properties

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
org.gradle.jvmargs=-Xmx1536M
2+
android.enableR8=true

example/lib/main.dart

+8-74
Original file line numberDiff line numberDiff line change
@@ -17,66 +17,20 @@ void main() {
1717
runApp(MyApp());
1818
}
1919

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 {
2921
@override
3022
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(),
6928
),
7029
);
7130
}
7231
}
7332

74-
class EnterPage extends StatefulWidget {
75-
@override
76-
_EnterPageState createState() => _EnterPageState();
77-
}
78-
79-
class _EnterPageState extends State<EnterPage> {
33+
class EnterPage extends StatelessWidget {
8034
@override
8135
Widget build(BuildContext context) {
8236
return Scaffold(
@@ -88,33 +42,13 @@ class _EnterPageState extends State<EnterPage> {
8842
alignment: Alignment.topCenter,
8943
child: SingleChildScrollView(
9044
child: Container(
91-
margin: EdgeInsets.only(top: 5),
45+
margin: EdgeInsets.only(top: 30),
9246
child: Column(children: <Widget>[
9347
Text(
9448
"Notification",
9549
style: TextStyle(fontWeight: FontWeight.w500, fontSize: 20),
9650
),
9751
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-
),
11852
Row(
11953
children: <Widget>[
12054
Expanded(

0 commit comments

Comments
 (0)