Flutter提示弹框

参考:https://github.com/inRush/TipDialog

(1)使用TipDialogContainer全局注册TipDialogController

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/// Use [TipDialogContainer] globally
/// This widget can be globally supported
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return new TipDialogContainer(
child: new MaterialApp(
title: 'TipDialog Demo',
theme: new ThemeData(),
home: new MyHomePage(title: 'TipDialog Demo Home Page'),
));
}
}

(2)使用TipDialogConnector获取TipDialogController

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/// Use [TipDialogConnector] to obtain [TipDialogController]
new TipDialogConnector(
builder: (context, tipController) {
return new ListView(children: <Widget>[
_buildItem("Loading Type Tip Dialog", () async {
tipController.show(
tipDialog: new TipDialog(type: TipDialogType.LOADING, tip: "Loading"),
isAutoDismiss: false);
await new Future.delayed(new Duration(seconds: 3));
tipController.dismiss();
}),
new Divider(),
_buildItem("Success Type Tip Dialog", () async {
tipController.show(
tipDialog: new TipDialog(
type: TipDialogType.SUCCESS,
tip: "Loaded Successfully",
));
}),
]);
},
)

Powered by AppBlog.CN     浙ICP备14037229号

Copyright © 2012 - 2020 APP开发技术博客 All Rights Reserved.

访客数 : | 访问量 :