代码组件:

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. Spring-02 -Spring 创建对象的三种方式 :1.通过构造方法创建/2.实例工厂/3.静态工厂

    通过构造方法创建  1.1 无参构造创建:默认情况. 1.2 有参构造创建:需要明确配置 1.2.1 需要在类中提供有参构造方法 1.2.2 在 applicationContext.xml 中设置调 ...

  2. python操作excel(xlwt写,xlrd读)基本方法

    python操作excle在测试工作中还是很有用的,比如读取测试数据,回写测试结果到excel. 1.安装 pip install xlwt pip install xlrd 2.写excel # 导 ...

  3. LINUX系统的常用知识

    常用的命令: man config   查看linux里面所有命令的详细描述 man pwd   按回车是一行一行的走,按空格是一页一页的走,按q键是退出的意思 mkdir test   创建文件夹p ...

  4. Dubbo源码分析(5):ExtensionLoader

    背景 Dubbo所有的模块加载是基于SPI机制的.在接口名的上一行加个@SPI注解表明要此模块要通过ExtensionLoader加载.基于SPI机制的扩展性比较好,在不修改原有代码,可以实现新模块的 ...

  5. Maximal Square II

    Description Given a 2D binary matrix filled with 0's and 1's, find the largest square which diagonal ...

  6. Java【基础学习】向下转型和上转型例子

    Java小白应付期末考试QWQ class Animal{ public void move() { System.); } } class Dog extends Animal{ public vo ...

  7. Hadoop上 Hive 操作

    数据dept表的准备: --创建dept表 CREATE TABLE dept( deptno int, dname string, loc string) ROW FORMAT DELIMITED ...

  8. IP地址与Mac地址绑定错误

    有个application,有时候可以正常访问,有时候又返回404错误,百思不得其解.刚开始以为是文件夹权限问题,折腾了好久. 后来没在服务器上monitor到包,所以猜想是到了错误的mac地址,用a ...

  9. 37、数据源之通用的load和save操作

    一.通用的load和save操作 1.概述 对于Spark SQL的DataFrame来说,无论是从什么数据源创建出来的DataFrame,都有一些共同的load和save操作. load操作主要用于 ...

  10. CODE FESTIVAL 2017 qual C 题解

    传送门 \(A\) 咕咕 const int N=15; char s[N];int n; int main(){ scanf("%s",s+1),n=strlen(s+1); f ...