https://medium.com/flutterdev...
在 flutter 中,咱們顯示任何進度指示器,由於咱們的應用程序是繁忙的或在擱置,爲此,咱們顯示一個循環的進度指示器。覆蓋加載屏幕顯示一個進度指示器,也稱爲模態進度 HUD 或平視顯示,這一般意味着應用程序正在加載或執行一些工做。android
在本文中,咱們將利用 HUD 進程程序包來探討平視顯示器在 flutter 方面的進展。有了這個軟件包,咱們能夠很容易地實現平視顯示的顫振進度。那麼讓咱們開始吧。git
https://pub.dev/packages/flut...github
https://pub.dev/packages/flut...編程
Flutter HUD Progress 是一種進度指示器庫,就像一個循環的進度指示器。在這裏,HUD 意味着一個擡頭顯示器/進度彈出對話框將打開以上的屏幕,將有一個循環的進度指示器。使用這個庫,咱們能夠使用咱們的 flutter 。應用程序能夠顯示循環進度指示器。api
將依賴項添加到 pubspec ー yaml 文件。微信
dependencies: flutter_progress_hud: ^2.0.0
import 'package:flutter_progress_hud/flutter_progress_hud.dart';
org.gradle.jvmargs=-Xmx1536M android.enableR8=true android.useAndroidX=true android.enableJetifier=true
在 lib
目錄中建立一個名爲 progress_hud_demo.dart
的新 dart 文件。app
在建立 Flutter HUD Progress 以前,咱們包裝了一個進度遮光罩的容器,其次是建設者類。在內部,咱們使用了咱們的小部件,並定義了進度指示器的邊框顏色和背景顏色。讓咱們詳細地瞭解一下這一點。jvm
ProgressHUD( borderColor:Colors.orange, backgroundColor:Colors.blue.shade300, child:Builder( builder:(context)=>Container( height:DeviceSize.height(context), width:DeviceSize.width(context), padding:EdgeInsets.only(left:20,right:20,top:20), ), ), ),
如今咱們已經採起了一個按鈕,在其中指示器設置持續時間 5 秒的指示器時間將來。delayed()
並顯示進度的文本。編程語言
Container( margin: EdgeInsets.only( left:20.0, right:20.0, top:55.0), child: CustomButton( mainButtonText:'Submit', callbackTertiary:(){ final progress = ProgressHUD.of(context); progress.showWithText('Loading...'); Future.delayed(Duration(seconds:5), () { progress.dismiss(); }); }, color:Colors.blue, ), ),
當咱們運行應用程序時,咱們應該獲得屏幕的輸出,就像下面的屏幕截圖同樣。ide
import 'package:flutter/material.dart'; import 'package:progress_hud_demo/shared/custom_button.dart'; import 'package:progress_hud_demo/shared/custom_text_field.dart'; import 'package:progress_hud_demo/themes/device_size.dart'; import 'package:flutter_progress_hud/flutter_progress_hud.dart'; class ProgressHudDemo extends StatefulWidget { @override _ProgressHudDemoState createState() => _ProgressHudDemoState(); } class _ProgressHudDemoState extends State<ProgressHudDemo> { bool _isInAsyncCall = false; @override Widget build(BuildContext context) { return Scaffold( backgroundColor:Colors.white, appBar:AppBar( backgroundColor:Colors.blue, title:Text('Flutter HUD Progress Demo'), elevation:0.0, ), body:ProgressHUD( borderColor:Colors.orange, backgroundColor:Colors.blue.shade300, child:Builder( builder:(context)=>Container( height:DeviceSize.height(context), width:DeviceSize.width(context), padding:EdgeInsets.only(left:20,right:20,top:20), child:Column( crossAxisAlignment:CrossAxisAlignment.start, children: [ Column( crossAxisAlignment:CrossAxisAlignment.start, children: [ Text('Sign In',style:TextStyle(fontFamily:'Roboto Bold',fontSize:27,fontWeight:FontWeight.bold),), ], ), SizedBox(height:50,), Column( children: [ CustomTextField(hintText: 'Email', type:TextInputType.text, obscureText: false), SizedBox(height:35,), CustomTextField(hintText: 'Password', type:TextInputType.text, obscureText: true), ], ), Container( margin: EdgeInsets.only( left:20.0, right:20.0, top:55.0), child: CustomButton( mainButtonText:'Submit', callbackTertiary:(){ final progress = ProgressHUD.of(context); progress.showWithText('Loading...'); Future.delayed(Duration(seconds:5), () { progress.dismiss(); }); }, color:Colors.blue, ), ), ], ), ), ), ), ); } }
© 貓哥
https://github.com/ducafecat/...
https://github.com/ducafecat/...
https://ducafecat.tech/catego...
https://space.bilibili.com/40...
https://space.bilibili.com/40...
https://space.bilibili.com/40...
https://space.bilibili.com/40...
https://space.bilibili.com/40...
https://space.bilibili.com/40...