Flutter 优雅地实现一个弹窗类型的Loading
2020/11/24 20:55:28
本文主要是介绍Flutter 优雅地实现一个弹窗类型的Loading,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
使用方式
showDialog( barrierDismissible: false, barrierColor: Colors.transparent, context: context, builder: (BuildContext context) { return Center( child:Container( width: 80,height: 80, child:CircularProgressIndicator( strokeWidth: 3.0, backgroundColor: Colors.blue, valueColor: new AlwaysStoppedAnimation<Color>(Colors.red), ), ) ); });
FadeRoute类的实现
import 'package:flutter/material.dart'; class FadeRoute extends PageRoute { FadeRoute({ @required this.pageBuilder, this.transitionDuration = const Duration(milliseconds: 300), this.opaque = true, this.barrierDismissible = false, this.barrierColor, this.barrierLabel, this.maintainState = true, }); final WidgetBuilder pageBuilder; @override final Duration transitionDuration; @override final bool opaque; @override final bool barrierDismissible; @override final Color barrierColor; @override final String barrierLabel; @override final bool maintainState; @override Widget buildPage(BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation) => pageBuilder(context); @override Widget buildTransitions(BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) { return FadeTransition( opacity: animation, child: pageBuilder(context), ); } }
第一段代码showDialog中的builder可以通过
自定义组件来抽出来,订制各种风格
移除loading的方法
Navigator.maybePop(context);
这篇关于Flutter 优雅地实现一个弹窗类型的Loading的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-01-18android.permission.read_media_video
- 2024-01-18android_getaddrinfo failed eai_nodata
- 2024-01-18androidmo
- 2024-01-15Android下三种离屏渲染技术
- 2024-01-09Android 蓝牙使用
- 2024-01-06Android对接华为AI - 文本识别
- 2023-11-15代码安全之代码混淆及加固(Android)
- 2023-11-10简述Android语音播报TTS
- 2023-11-06Android WiFi工具类
- 2023-07-22Android开发未来的出路