代码组件:

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:zhongfa_apps/services/ScreenAdapter.dart'; ///加载弹框
class ProgressDialog {
static bool _isShowing = false; ///展示 {Widget child = const CircularProgressIndicator(valueColor: AlwaysStoppedAnimation(Colors.red),)}
static void showProgress(BuildContext context) {
if (!_isShowing) {
_isShowing = true;
Navigator.push(
context,
_PopRoute(
child: _Progress(
child: new Padding(
padding: const EdgeInsets.all(12.0),
child: new Center(
//保证控件居中效果
child: new SizedBox(
width: 120.0,
height: 120.0,
child: new Container(
decoration: ShapeDecoration(
color: Colors.black54,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(8.0),
),
),
),
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
new CircularProgressIndicator(
backgroundColor: Colors.white,
strokeWidth: 4.0,
valueColor:
new AlwaysStoppedAnimation(Colors.black38),
),
new Padding(
padding: const EdgeInsets.only(
top: 20.0,
),
child: new Text(
"加载中...",
style: new TextStyle(
fontSize: ScreenAdapter.size(),
color: Colors.white),
),
),
],
),
),
),
),
),
),
),
);
}
} ///隐藏
static void hideProgress(BuildContext context) {
if (_isShowing) {
Navigator.of(context).pop();
_isShowing = false;
}
}
} ///Widget
class _Progress extends StatelessWidget {
final Widget child; _Progress({
Key key,
@required this.child,
}) : assert(child != null),
super(key: key); @override
Widget build(BuildContext context) {
return Material(
color: Colors.transparent,
child: Center(
child: child,
));
}
} ///Route
class _PopRoute extends PopupRoute {
final Duration _duration = Duration(milliseconds: );
Widget child; _PopRoute({@required this.child}); @override
Color get barrierColor => null; @override
bool get barrierDismissible => true; @override
String get barrierLabel => null; @override
Widget buildPage(BuildContext context, Animation<double> animation,
Animation<double> secondaryAnimation) {
return child;
} @override
Duration get transitionDuration => _duration;
}

页面调用:

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:zhongfa_apps/widget/public/ProgressDialog.dart'; class Test003 extends StatefulWidget {
Test003({Key key}) : super(key: key); @override
_Test003State createState() => _Test003State();
} class _Test003State extends State<Test003> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("测试页面"),
),
body: Container(
child: InkWell(
onTap: () {
ProgressDialog.showProgress(context);
print("打印");
Timer _timer;
_timer = Timer.periodic(Duration(seconds: ),(res){
ProgressDialog.hideProgress(context);
_timer.cancel(); });
},
child: Text("加载",style: TextStyle(
fontSize:
)),
),
),
);
}
}

flutter的加载弹框的更多相关文章

  1. 加载旋转框(loading spinner)

    目标是这样的 用到的组件 AlertDialog 和 ProgressBar 先创建一个 AlertDialog 的布局 <?xml version="1.0" encodi ...

  2. IOS开发UI篇之──自定义加载等待框(MBProgressHUD)

    本文转载至 http://blog.csdn.net/xunyn/article/details/8064984   原文地址http://www.189works.com/article-89289 ...

  3. 安卓 自定义AlertDialog对话框(加载提示框)

    AlertDialog有以下六种使用方法: 一.简单的AlertDialog(只显示一段简单的信息) 二.带按钮的AlertDialog(显示提示信息,让用户操作) 三.类似ListView的Aler ...

  4. Flutter ------- WebView加载网页

    在Flutter 加载网页?也是有WebView的哦,和Android一样 1.添加依赖 dependencies: flutter_webview_plugin: ^0.2.1+2 2.导入库 im ...

  5. js 滚动加载iframe框中内容

    var isIE6 = !!window.ActiveXObject&&!window.XMLHttpRequest; //滚动加载 var scrollLoad =function( ...

  6. Extjs treePanel 加载等待框

    beforeload : { fn : function (store, operation, eOpts){ loadMask = new Ext.LoadMask(Ext.get(this.get ...

  7. angularJS配合bootstrap动态加载弹出提示内容

    1.bootstrp的弹出提示 bootstrap已经帮我们封装了非常好用的弹出提示Popover. http://v3.bootcss.com/javascript/#popovers 2.自定义p ...

  8. yii2 页面加载警告框

    在视图页面代码如下 <?php use kartik\alert\Alert; echo Alert::widget([ 'type' => Alert::TYPE_INFO, 'titl ...

  9. vue图片预加载

    目的: 图片预加载能够使得用户在浏览后续页面的时候,不会出现图片加载一半导致浏览不流畅的情况. 一.方法一 项目打开的时候要对图片进行预加载,在App.vue里面的beforeCreate添加预加载程 ...

随机推荐

  1. 大数据之路week07--day07 (Sqoop 从mysql增量导入到HDFS)

    我们之前导入的都是全量导入,一次性全部导入,但是实际开发并不是这样,例如web端进行用户注册,mysql就增加了一条数据,但是HDFS中的数据并没有进行更新,但是又再全部导入一次又完全没有必要. 所以 ...

  2. 《The One!团队》第八次作业:ALPHA冲刺(一)

    项目 内容 作业所属课程 所属课程 作业要求 作业要求 团队名称 < The One !> 作业学习目标 (1)掌握软件测试基础技术.(2)学习迭代式增量软件开发过程(Scrum) 第一天 ...

  3. c++中的static,const,const static以及它们的初始化

    const定义的常量在超出其作用域之后其空间会被释放,而static定义的静态常量在函数执行后不会释放其存储空间. static表示的是静态的.类的静态成员函数.静态成员变量是和类相关的,而不是和类的 ...

  4. DELL 管理软件安装

    dell不进入bios修改cpu为高性能的方法:(在下次重启后生效) 首先安装omsa:安装方法: http://linux.dell.com/repo/hardware/Linux_Reposito ...

  5. 洛谷 P1439 【模板】最长公共子序列 题解

    每日一题 day40 打卡 Analysis 因为两个序列都是1~n 的全排列,那么两个序列元素互异且相同,也就是说只是位置不同罢了,那么我们通过一个book数组将A序列的数字在B序列中的位置表示出来 ...

  6. 洛谷 AT2434 JOI 公園 (JOI Park) 题解

    人生第一次AC黑题,我太感动了. 每日一题 day31 打卡 Analysis 先跑遍DJ,求出1到 i的最短路.得到每个点到 1号点的距离后,从小到大排序一遍,这时便可以枚举每个点到 1号点的距离修 ...

  7. 浏览器URL中“#” “?” &“”作用

    1. # 10年9月,twitter改版.一个显著变化,就是URL加入了"#!"符号.比如,改版前的用户主页网址为http://twitter.com/username改版后,就变 ...

  8. Bzoj 2875: [Noi2012]随机数生成器(矩阵乘法)

    2875: [Noi2012]随机数生成器 Time Limit: 10 Sec Memory Limit: 512 MB Submit: 2052 Solved: 1118 Description ...

  9. 红黑树 ------ luogu P3369 【模板】普通平衡树(Treap/SBT)

    二次联通门 : luogu P3369 [模板]普通平衡树(Treap/SBT) 近几天闲来无事...就把各种平衡树都写了一下... 下面是红黑树(Red Black Tree) 喜闻乐见拿到了luo ...

  10. github提示Permission denied (publickey),如何才能解决?

    参考: https://my.oschina.net/u/1377923/blog/1822038 https://www.cnblogs.com/chjbbs/p/6637519.html