携手创作,共同生长!这是我参加「日新计划 8 月更文挑战」的第30天,点击查看活动概况
本文主要介绍下flutter中进展条的运用
LinearProgressIndicator
LinearProgressIndicator
线性进展指示器,也称为进展条。承继ProgressIndicator
const LinearProgressIndicator({
Key? key,
double? value,
Color? backgroundColor,
Color? color,
Animation<Color?>? valueColor,
this.minHeight,
String? semanticsLabel,
String? semanticsValue,
})
水平进展指示器,根本用法如下
Scaffold(
appBar: AppBar(title: Text('Indicator'),),
body:LinearProgressIndicator(),
floatingActionButton: FloatingActionButton(
child: const Icon(Icons.navigate_next),
onPressed: () {
},),
);
作用如下:

通过value
设置详细
LinearProgressIndicator(
value: 0.4,
)
value
的值范围是0-1,作用如下:

const LinearProgressIndicator(
value: 0.4,
backgroundColor: Colors.yellowAccent,
valueColor: AlwaysStoppedAnimation<Color>(Colors.black)
)
作用如下:

CircularProgressIndicator
CircularProgressIndicator
是圆形进展条,和LinearProgressIndicator
用法相同:
const CircularProgressIndicator({
Key? key,
double? value,
Color? backgroundColor,
Color? color,
Animation<Color?>? valueColor,
this.strokeWidth = 4.0,
String? semanticsLabel,
String? semanticsValue,
})
简略运用:
CircularProgressIndicator()
作用如下:

设置进展值及颜色值:
CircularProgressIndicator(
value: 0.3,
backgroundColor: Colors.blue,
valueColor: AlwaysStoppedAnimation<Color>(Colors.redAccent),
)
作用如下图所示:

CupertinoActivityIndicator
CupertinoActivityIndicator
是咱们iOS中加载风格的指示器,CupertinoActivityIndicator不能设置进展,只能一直转“菊花”
const CupertinoActivityIndicator({
Key? key,
this.color,
this.animating = true,
this.radius = _kDefaultIndicatorRadius,
})
运用默许
CupertinoActivityIndicator()
作用如下:

radius
参数是半径,值越大,控件越大。
CupertinoActivityIndicator(
radius: 60,
color: Colors.redAccent,
)
作用如下:

flutter_progress_hud
覆盖加载屏幕显现一个进展指示器,也称为模态进展 HUD 或平视显现,这一般意味着应用程序正在加载或履行一些作业。 咱们也能够运用一些三方的加载flutter_progress_hud:
ProgressHUD(
borderColor:Colors.orange,
backgroundColor:Colors.blue.,
child:Builder(
builder:(context)=>Container(
height:DeviceSize.height(context),
width:DeviceSize.width(context),
padding:EdgeInsets.only(left:20,right:20,top:20),
),
),
),
咱们也能够根据context 初始化
final progress = ProgressHUD.of(context);
show
progress.show();
增加提示语
progress.showWithText('Loading...');
消失
progress.dismiss();

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。