我试图显示小部件(圆圈)的列表,但我想扩展它们并使圆圈占据整个页面。我尝试了不同的方法;我使用flexibe,flex和扩展。但是,它们都没有起作用。你能推荐一下吗? 提前致谢! 编辑:这是代码: //步进圈是我要在它们之间展开的小部件
return Expanded(
flex: 10,
child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children:
List<Widget>.generate( numberOfCircles,
(int index) {
return StreamBuilder(
stream: stepperBloc.statusStream,
initialData: {0:"incomplete", 1:"incomplete", 2:"incomplete"},
builder:(_, AsyncSnapshot statusSnapshot){
if(statusSnapshot.hasData){
return Row(
children:<Widget>[ Flexible(
flex:5,
child: StepperCircle(
index: index,
status: statusSnapshot.data[index],
// onTap: () => stepperBloc.statusSink({index: "selected"}),
),
)],
);
答案 0 :(得分:1)
您可以尝试使用PageView
小部件,它会扩展每个项目以填充屏幕(根据viewportFraction
值),并且可以设置垂直或水平方向。
PageController controller = PageController(viewportFraction: 1.0);
return PageView(
controller: controller,
scrollDirection: Axis.vertical,
children: <Widget>[
Container(
color: Colors.red,
),
Container(
color: Colors.blue,
),
Container(
color: Colors.yellow,
),
],
);
更多信息:https://docs.flutter.io/flutter/widgets/PageView-class.html