El *_*bre 2 flutter flutter-layout
在 Flutter 中,我有LinearProgressIndicator。有效,但我想在此栏内添加文本(进度)。
我尝试这样的事情
SafeArea(
child: Row(children: <Widget>[
Center(
child: Text(DateFormat.ms()
.format(DateTime.fromMillisecondsSinceEpoch(
minuteSecond * 1000))
.toString())),
Expanded(
child: LinearProgressIndicator(
semanticsLabel: (animation.value * 100.0).toStringAsFixed(1).toString(),
semanticsValue: (animation.value * 100.0).toStringAsFixed(1).toString(),
value: animation.value,
backgroundColor: Colors.white,
valueColor:
AlwaysStoppedAnimation<Color>(Colors.red))),
])),
Run Code Online (Sandbox Code Playgroud)
但显然这将文本添加在栏的同一行中,而不是在里面。
所以:有人知道我如何在这个栏中添加中心(居中)?使用堆栈元素?
更新
有人知道如何在 ProgressBar 中垂直对齐文本吗?
你必须使用Stack,试试这个:
为简单起见,我对0.6值进行了硬编码,您可以animation.value在其中使用您的值。
Stack(
children: <Widget>[
SizedBox(
height: 20,
child: LinearProgressIndicator(
value: 0.6,
backgroundColor: Colors.white,
valueColor: AlwaysStoppedAnimation<Color>(Colors.red),
),
),
Align(child: Text("Text"), alignment: Alignment.topCenter,),
],
)
Run Code Online (Sandbox Code Playgroud)
截屏:
| 归档时间: |
|
| 查看次数: |
2257 次 |
| 最近记录: |