flutter开发实战-flutter_spinkit实现多种风格进度指示器
最近开发过程中flutter_spinkit,这个拥有多种种风格加载指示器
一、flutter_spinkit
引入flutter_spinkit
# 多种风格的模糊进度指示器
flutter_spinkit: ^5.1.0
效果示例
const spinkit = SpinKitRotatingCircle(
color: Colors.white,
size: 50.0,
);
final spinkit = SpinKitFadingCircle(
itemBuilder: (BuildContext context, int index) {
return DecoratedBox(
decoration: BoxDecoration(
color: index.isEven ? Colors.red : Colors.green,
),
);
},
);
final spinkit = SpinKitSquareCircle(
color: Colors.white,
size: 50.0,
controller: AnimationController(vsync: this, duration: const Duration(milliseconds: 1200)),
);
二、实现指示器效果
代码如下文章来源:https://www.toymoban.com/news/detail-631308.html
import 'package:flutter/material.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
/// 加载中
class LoadingWidget extends StatelessWidget {
const LoadingWidget({this.bgColor, Key? key}) : super(key: key);
final Color? bgColor;
Color getColorAtIndex(int index) {
if (index == 0) {
return Colors.deepOrangeAccent;
}
if (index == 1) {
return Colors.redAccent;
}
if (index == 1) {
return Colors.lightBlueAccent;
}
return Colors.white70;
}
Widget build(BuildContext context) {
return Container(
color: bgColor != null ? bgColor : Colors.white,
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(
width: 300.0,
height: 60.0,
child: SpinKitThreeBounce(
size: 40.0,
itemBuilder: (BuildContext context, int index) {
return DecoratedBox(
decoration: BoxDecoration(
color: getColorAtIndex(index),
shape: BoxShape.circle));
},
),
),
Padding(padding: const EdgeInsets.only(top: 20)),
Text(
//S.of(context).viewStateLoading,
"正在加载中,一会就到了",
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w500,
fontStyle: FontStyle.normal,
color: Colors.white,
decoration: TextDecoration.none,
),
)
],
),
),
);
}
}
三、小结
flutter开发实战-flutter_spinkit实现多种风格进度指示器.
学习记录,每天不停进步。文章来源地址https://www.toymoban.com/news/detail-631308.html
到了这里,关于flutter开发实战-flutter_spinkit实现多种风格进度指示器的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!