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添加预加载程 ...
随机推荐
- 《CoderXiaoban》第八次团队作业:Alpha冲刺5
项目 内容 这个作业属于哪个课程 任课教师博客主页链接 这个作业的要求在哪里 实验十二 团队作业8:软件测试与ALPHA冲刺 团队名称 Coderxiaoban团队 作业学习目标 (1)掌握软件测试基 ...
- 阿里云 Windows Server 2012 密码过期设置
不加入域的情况下: 1.服务器管理器>工具>本地安全策略>账户策略>密码策略>密码最长使用期限(修改为0天)或者禁用密码复杂度要求 参考:https://blog.csd ...
- 使用VISIO绘制组织结构图的操作方法
1.确保电脑已安装VISIO软件,然后在电脑指定位置点击鼠标右键新建VISIO绘图文档. 2.打开文档,在弹出的选择绘图类型中点击商务.组织结构图,之后点击确定. 3.之后进入绘图主界面,在左侧是形状 ...
- 微信小程序引入Vant组件库
前期准备 Vant Weapp组件库:https://youzan.github.io/vant-weapp/#/intro 1.先在微信开发者工具中打开项目的终端: 然后初始化一个package.j ...
- 瀑布流(基于Django)
# 后端 from django.shortcuts import render, HttpResponse from django.http import JsonResponse from app ...
- 初始SpringBoot
导入依赖 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http:/ ...
- C# 异步的简单用法
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- (尚010)Vue列表的搜素和排序
1.test010.html <!DOCTYPE html><html lang="en"><head> <meta charset=&q ...
- 洛谷P1901发射站
题目 一道单调栈裸题,主要是用单调栈维护单调性,和单调队列都可以在\(O(n)\)的时间内得出单调最大值或最小值,要比堆要快. 这个题可以用h来当做单调栈的使用对象,即用单调栈来维护高度,高度是越在栈 ...
- synology git 服务器问题处理
synology git 服务器问题处理 安装 synology 上的 git 套件, 发现使用过程中存在很多问题. permission 问题 ## 将对应的目录设为git所有者 chown git ...