【问题标题】:Is there any way i can display LinearProgress on top of existing widgets?有什么方法可以在现有小部件之上显示 LinearProgress 吗?
【发布时间】:2020-07-24 04:28:16
【问题描述】:

我想在我的 Row 小部件上显示完成的进度。 像这样:

(忽略箭头)。

目前,我在行下方添加了线性进度。像这样:

有什么方法可以实现吗? 这是我当前的代码:

Row(
                mainAxisAlignment: MainAxisAlignment.spaceAround,
                children: <Widget>[
                  Column(
                    children: <Widget>[
                      Text("Raised",style: TextStyle(fontSize: 18),),
                      SizedBox(height: 10,),
                      Text(raisedAmount.toString()+"₹",style: TextStyle(fontSize: 26,fontWeight: FontWeight.bold),)                          
                    ],
                  ),
                  Column(
                    children: <Widget>[
                      Text("Target",style: TextStyle(fontSize: 18),),
                      SizedBox(height: 10,),
                      Text(targetAmount.toString()+"₹",style: TextStyle(fontSize: 26,fontWeight: FontWeight.bold),)                         
                    ],
                  )
                ],
              ),
LinearProgressIndicator(
              value: progress,
              backgroundColor: Colors.grey[200],
              valueColor: AlwaysStoppedAnimation<Color>(
                Colors.deepOrange[200],
                ),                    
            ),

【问题讨论】:

    标签: flutter dart android-widget flutter-layout


    【解决方案1】:

    您可以使用 Stack 来完成此操作...

    Stack(
          children:[ 
            LinearProgressIndicator(minHeight: 60,
                  value: progress,
                  backgroundColor: Colors.grey[200],
                  valueColor: AlwaysStoppedAnimation<Color>(
                    Colors.deepOrange[200],
                    ),                    
                ),
                   Row(
                      mainAxisAlignment: MainAxisAlignment.spaceAround,
                      children: <Widget>[
                        Column(
                          children: <Widget>[
                            Text("Raised",style: TextStyle(fontSize: 18),),
                            SizedBox(height: 10,),
                            Text(raisedAmount.toString()+"₹",style: TextStyle(fontSize: 26,fontWeight: FontWeight.bold),)                          
                          ],
                        ),
                        Column(
                          children: <Widget>[
                            Text("Target",style: TextStyle(fontSize: 18),),
                            SizedBox(height: 10,),
                            Text(targetAmount.toString()+"₹",style: TextStyle(fontSize: 26,fontWeight: FontWeight.bold),)                         
                          ],
                        )
                     ],
                  ),
             ]
        );
    

    【讨论】:

    • LinearProgressIndicator 没有 minHeight 参数
    • 是的,它有...你应该检查一下...你使用的是哪个版本的颤振???....如果较低版本,则将其包装在容器中并给它一个高度
    • 我使用的是 1.17.1,不,我也检查了文档,它没有任何高度参数。无论如何,谢谢,包装在容器中并添加高度可以正常工作。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-11-08
    • 1970-01-01
    • 2013-06-16
    • 1970-01-01
    • 2020-12-23
    • 2021-02-02
    • 2019-04-03
    相关资源
    最近更新 更多