class _DemoPageState extends State<DemoPage> {
final int currentIndex = 0;
@override
Widget build(BuildContext context) {
return IndexedStack(
//所以指定谁,就显示谁,这里0表示第一个child,所以显示CircleAvatar
index: currentIndex,
children: [
CircleAvatar(
backgroundColor: Colors.green,
radius: 50.0,
),
Container(
decoration: BoxDecoration(
color: Colors.black12,
),
child: Text(
'IndexedStack',
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.bold,
color: Colors.white),
),
)
],
);
}
}
Flutter笔记52:IndexedStack索引层叠组件
IndexedStack索引层叠组件,Index-索引,Stack-层叠,有索引的层叠组件,根据索引,显示它的子元素,不管多少个子元素,只显示指定的哪个:
