Flutter LinearProgressIndicator 设置高度 以及设置进度条颜色渐变 flutter 控件隐藏

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"),
            ],
          ),

 

  • 4
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值