在窗口小部件flutter中调整窗口小部件的大小



我需要一些帮助,我不知道谁应该让小部件白色80宽蓝色,子小部件白色10宽橙色。我试了一下,但所有的小部件似乎都有10的宽度。我做得不好吗?

LayoutBuilder是她的cose我想要我的小部件prompte宽度%的进度厚度以获得您的帮助sry为我的英语


class ProgressBar extends StatelessWidget {
const ProgressBar({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
return SizedBox(
width: 80,
height: 20,
child: Container(
color: Colors.blue,
child: SizedBox(
width: 10,
height: 20,
child: Container(
color: Colors.orange,
),
)));
},
);
}
}

像这样使用FittedBox

return SizedBox(
width: 80,
height: 20,
child: FittedBox(
child: Container(
color: Colors.blue,
child: SizedBox(
width: 10,
height: 20,
child: Container(
color: Colors.orange
),
),
),
),
);

最新更新