如何在 Flutter 中将一个 CircularProgressIndicator 放入另一个 CircularProgressIndicator 中?
How to put a CircularProgressIndicator inside another CircularProgressIndicator in Flutter?
我试过这样做,但结果一个接一个。 CircularProgressIndicator
堆叠在一起,而不是像我在以下代码中尝试的那样在里面:
body: Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
SizedBox(
height: 200,
width: 200,
child: Column(
children: <Widget>[
CircularProgressIndicator(
backgroundColor: Colors.pinkAccent,
strokeWidth: 30.0,
value: 0.7,
valueColor: AlwaysStoppedAnimation<Color>(Colors.black),
),
SizedBox(
height: 150,
width: 150,
child: CircularProgressIndicator(
backgroundColor: Colors.red,
strokeWidth: 10.0,
value: 0.7,
valueColor: AlwaysStoppedAnimation<Color>(Colors.black),
),
),
],
),
),
],
),
),
您必须使用堆叠小部件将这些小部件堆叠在一起
Stack(
children: <Widget>[
SizedBox(
height: 200,
width: 200,
child: CircularProgressIndicator(
backgroundColor: Colors.pinkAccent,
strokeWidth: 30.0,
value: 0.7,
valueColor: AlwaysStoppedAnimation<Color>(Colors.black),
),
),
Positioned(
left: 25,
top: 25,
child: SizedBox(
height: 150,
width: 150,
child: CircularProgressIndicator(
backgroundColor: Colors.red,
strokeWidth: 10.0,
value: 0.7,
valueColor: AlwaysStoppedAnimation<Color>(Colors.black),
),
),
)
],
),
输出
我试过这样做,但结果一个接一个。 CircularProgressIndicator
堆叠在一起,而不是像我在以下代码中尝试的那样在里面:
body: Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
SizedBox(
height: 200,
width: 200,
child: Column(
children: <Widget>[
CircularProgressIndicator(
backgroundColor: Colors.pinkAccent,
strokeWidth: 30.0,
value: 0.7,
valueColor: AlwaysStoppedAnimation<Color>(Colors.black),
),
SizedBox(
height: 150,
width: 150,
child: CircularProgressIndicator(
backgroundColor: Colors.red,
strokeWidth: 10.0,
value: 0.7,
valueColor: AlwaysStoppedAnimation<Color>(Colors.black),
),
),
],
),
),
],
),
),
您必须使用堆叠小部件将这些小部件堆叠在一起
Stack(
children: <Widget>[
SizedBox(
height: 200,
width: 200,
child: CircularProgressIndicator(
backgroundColor: Colors.pinkAccent,
strokeWidth: 30.0,
value: 0.7,
valueColor: AlwaysStoppedAnimation<Color>(Colors.black),
),
),
Positioned(
left: 25,
top: 25,
child: SizedBox(
height: 150,
width: 150,
child: CircularProgressIndicator(
backgroundColor: Colors.red,
strokeWidth: 10.0,
value: 0.7,
valueColor: AlwaysStoppedAnimation<Color>(Colors.black),
),
),
)
],
),
输出