flutter的加载弹框
代码组件:
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的加载弹框的更多相关文章
- 加载旋转框(loading spinner)
目标是这样的 用到的组件 AlertDialog 和 ProgressBar 先创建一个 AlertDialog 的布局 <?xml version="1.0" encodi ...
- IOS开发UI篇之──自定义加载等待框(MBProgressHUD)
本文转载至 http://blog.csdn.net/xunyn/article/details/8064984 原文地址http://www.189works.com/article-89289 ...
- 安卓 自定义AlertDialog对话框(加载提示框)
AlertDialog有以下六种使用方法: 一.简单的AlertDialog(只显示一段简单的信息) 二.带按钮的AlertDialog(显示提示信息,让用户操作) 三.类似ListView的Aler ...
- Flutter ------- WebView加载网页
在Flutter 加载网页?也是有WebView的哦,和Android一样 1.添加依赖 dependencies: flutter_webview_plugin: ^0.2.1+2 2.导入库 im ...
- js 滚动加载iframe框中内容
var isIE6 = !!window.ActiveXObject&&!window.XMLHttpRequest; //滚动加载 var scrollLoad =function( ...
- Extjs treePanel 加载等待框
beforeload : { fn : function (store, operation, eOpts){ loadMask = new Ext.LoadMask(Ext.get(this.get ...
- angularJS配合bootstrap动态加载弹出提示内容
1.bootstrp的弹出提示 bootstrap已经帮我们封装了非常好用的弹出提示Popover. http://v3.bootcss.com/javascript/#popovers 2.自定义p ...
- yii2 页面加载警告框
在视图页面代码如下 <?php use kartik\alert\Alert; echo Alert::widget([ 'type' => Alert::TYPE_INFO, 'titl ...
- vue图片预加载
目的: 图片预加载能够使得用户在浏览后续页面的时候,不会出现图片加载一半导致浏览不流畅的情况. 一.方法一 项目打开的时候要对图片进行预加载,在App.vue里面的beforeCreate添加预加载程 ...
随机推荐
- 51nod 1657 电子龟
电子龟的行动,是沿着直线左右走动的.他能够接受两种指令,“T”(向后转,即如果面向左,改成向右:否则就向左)和“F”(向当前面朝的方向往前移动一个单位距离). 现在给出一串指令,让电子龟来执行.你必须 ...
- 01.Vue前端路由学习目标
路由的基本概念与原理 vue-router的基本使用 vue-router嵌套路由 vue-router动态路由匹配 vue-router命名路由 vue-router编程式导航 基于vue-rout ...
- vue-router路由拦截基本设置,md5加密,js-cookie,vuex刷新页面store中的数据丢失等
vuex持久化 vuex-persistedstate
- UWB DWM1000 开源项目框架 之 温度采集
在之前博文开源一套uwb 框架,后面几篇博文会基于这个开源框架进行简单开发. 让uwb使用者更清楚了解基于这个basecode 开发工作. 这里所做内容是,采集dwm1000 温度,并发送到另一个节点 ...
- SpringBoot测试Controller层
一.准备工作 1.导入测试依赖 <dependency> <groupId>org.springframework.boot</groupId> <artif ...
- [Flutter] Router Navigation
Basic navigation by using 'Navigator.push' & 'Navigator.pop()', for example, we have two screen, ...
- MySQL 优化之EXPLAIN详解(执行计划)
学习MySQL时我们都知道索引对于一个SQL的优化很重要,而EXPLAIN关键字在分析是否正确以及高效的增加了索引时起到关键性的作用. 这篇文章显示了如何调用“EXPLAIN”来获取关于查询执行计划的 ...
- 4-STM32物联网开发WIFI(ESP8266)+GPRS(Air202)系统方案升级篇(远程升级WIFI内部程序)
https://www.cnblogs.com/yangfengwu/p/10360618.html 演示视频: https://www.bilibili.com/video/av54894356/ ...
- PKUSC2019 改题记录
PKUSC2019 改题记录 我真的是个sb... 警告:不一定是对的... D1T1 有一个国家由\(n\)个村庄组成,每个村庄有一个人.对每个\(i\in[1,n-1],\)第\(i\)个村庄到第 ...
- 复旦高等代数 I(15级)每周一题
[问题2015A01] 证明: 第三类分块初等变换是若干个第三类初等变换的复合. 特别地, 第三类分块初等变换不改变行列式的值. [问题2015A02] 设 $n\,(n\geq 2)$ 阶方阵 ...