Flutter控件的显示与隐藏 :
new Offstage(
offstage: true, //这里控制 当为true时控件隐藏
child: Container(color: Colors.blue,height: 100.0,),
),
Flutter的 LinearProgressIndicator不具备设置高度的选项,可以使用SizedBox来设置高度与宽度。
@override
Widget build(BuildContext context) {
return new SizedBox(
height: 2.0,
child: new LinearProgressIndicator(
value: animation.value,
backgroundColor: Colors.white,
valueColor: changeColor),
);
}
initState() {
super.initState();
controller = new AnimationController(
duration: const Duration(milliseconds: 10000), vsync: this);
animation = new Tween(begin: 1.0, end: 0.0).animate(controller)
..addStatusListener((status) {
if (status == AnimationStatus.completed) {
complete();
controller.reset();
controller.forward();
}
})
..addListener(() {
setState(() {});
});
controller.forward(
from: (new DateTime.now().millisecondsSinceEpoch / 1000 % 30) / 30.0);
changeColor = ColorTween(
begin: const Color(0xff5acd6c),
end: Colors.red,
).animate(
CurvedAnimation(
parent: controller,
curve: Interval(
0.83,
0.83,
curve: Curves.linear,
),
),
);
}
通过Animation<Color> changeColor可以设置进度条颜色的渐变。
效果图如下:
GridView 不显示下拉阴影:
去掉阴影:
new GridView(
//controller控制是否显示下拉阴影
controller: new ScrollController(keepScrollOffset: false),
gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(
// 横轴数量 这里的横轴就是x轴 因为方向是垂直的时候 主轴是垂直的
crossAxisCount: 3,
//主轴方向
mainAxisSpacing: 37.0,
//横轴方向间距
crossAxisSpacing: 30.0,
),
children: <Widget>[
_getLoadingInfo('Setting', "review.png", "router"),
],
),