解决方案1
使用
fit: StackFit.expand
Stack
:
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Stack(
fit: StackFit.expand,
children: [
LinearProgressIndicator(
value: 0.5,
valueColor: AlwaysStoppedAnimation<Color>(Color(0x88888888)),
),
Container(
child: Column(children: [
Text(
"Title",
textScaleFactor: 1.2,
style: TextStyle(color: Colors.white38),
),
Text(
"Content",
textScaleFactor: 2,
style: TextStyle(color: Colors.white),
)
])
)
],
);
}
}
解决方案2
Positioned.fill
LinearProgressIndicator
:
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Stack(
children: [
Positioned.fill(
child: LinearProgressIndicator(
value: 0.5,
valueColor: AlwaysStoppedAnimation<Color>(Color(0x88888888)),
),
),
Container(
child: Column(children: [
Text(
"Title",
textScaleFactor: 1.2,
style: TextStyle(color: Colors.white38),
),
Text(
"Content",
textScaleFactor: 2,
style: TextStyle(color: Colors.white),
)
])
)
],
);
}
}