有什么方法可以在现有小部件上显示LinearProgress?

时间:2020-07-24 04:28:16

标签: flutter dart android-widget flutter-layout

我想在“行”窗口小部件上显示完成的进度。 像这样:

enter image description here

(忽略箭头)。

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

enter image description here

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

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

1 个答案:

答案 0 :(得分:3)

您可以使用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),)                         
                      ],
                    )
                 ],
              ),
         ]
    );