参考
网上很多自定义弹窗界面,可以通过界面跳转的方式显示和隐藏,但是对于我来说有点难,因为弹窗往往会结合网络请求,这时候用插件的方式会好很多
插件地址如下
https://pub.flutter-io.cn/packages/flutter_easyloading
flutter_easyloading: ^3.0.3
首先在界面初始化
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter EasyLoading',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter EasyLoading'),
builder: EasyLoading.init(),
);
}
}
然后使用
EasyLoading.show(status: 'loading...');
EasyLoading.showProgress(0.3, status: 'downloading...');
EasyLoading.showSuccess('Great Success!');
EasyLoading.showError('Failed with Error');
EasyLoading.showInfo('Useful Information.');
EasyLoading.showToast('Toast');
EasyLoading.dismiss();