progress_toast 1.0.5
progress_toast: ^1.0.5 copied to clipboard
A lightweight progresss toast widget for Flutter, Easy to custom, Support iOS、Mac、Android and Web
ProgressToast
功能 #
当开始请求网络数据时,弹出一个Toast,提供默认或自定义的样式,提示用户当前正在请求数据,使用ProgressToast.loading 当网络请求完全时,也可弹出一个Toast,提示用户网络请求的结果,使用ProgressToast.text
添加依赖 #
在项目的pubspec.yaml中添加:
progress_toast: ^latest
接入步骤 #
##1.导入
import 'package:flutter_easyloading/flutter_easyloading.dart';
```dart
##2. 模拟网络请求并隐藏Toast:
```dart
ProgressToast.loading(
context: context, message: 'LOADING...');
Future.delayed(const Duration(seconds: 3)).then((value) {
ProgressToast.hide();
});
```dart
##3 模拟网络请求并显示Toast提示成功:
```dart
ProgressToast.loading(
context: context, message: 'LOADING...');
Future.delayed(const Duration(seconds: 3)).then((value) {
ProgressToast.text(context: context, message: 'SUCCESS!!!')
});
```dart
##4 自定义loading样式与Text样式
```dart
ProgressToast.loading(
context: context,
customWidget: Column(
mainAxisSize: MainAxisSize.min,
children: const <Widget>[
CupertinoActivityIndicator(
radius: 18, color: Colors.white),
SizedBox(height: 10),
Text('LOADING...',
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.center,
maxLines: 2,
style: TextStyle(
fontSize: 20,
color: Colors.white,
))
],
));
Future.delayed(const Duration(seconds: 3)).then((value) {
ProgressToast.text(
context: context,
customWidget: Column(
mainAxisSize: MainAxisSize.min,
children: const <Widget>[
Icon(
Icons.check_circle_outline,
size: 36,
color: Colors.green,
),
SizedBox(height: 10),
Text('SUCCESS!!!',
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.center,
maxLines: 2,
style: TextStyle(
fontSize: 20,
color: Colors.white,
))
],
));
});
```dart
## 更多信息
更多使用示例,使用请参考示例工程。
如有bug,欢迎发起PR,或联系:shawnli1201@gmail.com