扑:建立用户界面时执行大小错误?

时间:2018-12-10 21:55:54

标签: dart flutter

在这段代码中,我试图输出一个pickerCards列表,以使Container具有添加的属性。在尝试这样做时。我收到此错误,试图通过将所有小部件插入具有指定高度的容器中来指定高度,但遗憾的是它没有用。任何帮助将不胜感激。 找到随附的代码

class PackageScreenState extends State<PackageScreen> {
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
        appBar: new AppBar(
          title: new Text("Choose package"),
        ),
        body: 
          StreamBuilder<UnmodifiableListView<Package>>(
              stream: subscriptionBloc.package,
              builder:
                  (_, AsyncSnapshot<UnmodifiableListView<Package>> packages) {
                if (packages.hasData == true) {
                  return ListView.builder(
                           shrinkWrap: true,
                      itemCount: packages.data.length,
                      itemBuilder: ((BuildContext context, int index) {
                        return PackageContainer(
                          titleText: packages.data[index].name,
                          price: packages.data[index].price,
                          subtitleText: packages.data[index].description,
                          onPressed: null,
                        );
                      }));
                } //if end statment
                else {
                  return CircularProgressIndicator();
                }

        ));
  }
}

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:1)

shrinkWrap属性添加到您的ListView.builder

  shrinkWrap: true
豫ICP备18024241号-1