水平视口的高度不受限制,可能来自ListView.builder

时间:2019-07-15 03:26:51

标签: flutter flutter-layout

我正在尝试构建屏幕并显示用户使用ListView.builder()选择的图片,但它会引发错误并且不显示

我尝试使用SizedBox和rinkleWrap:是的,但是不起作用

@override
  Widget build(BuildContext context) {
    List<File> pictures = widget.pictures;

    final size = MediaQuery.of(context).size;
    final width = size.width;
    final height = size.height;

    Widget buildPicture(BuildContext ctxt, int index) {
      return Container(
          width: 300,
          height: 300,
          child: Image.file(pictures[index])
      );
    }

    return Scaffold(
        appBar: AppBar(title: Text('Display the Picture')),

        body: ListView(
            physics: NeverScrollableScrollPhysics(),
            padding: const EdgeInsets.all(8.0),
            children: <Widget>[
              Container(
                child: Text('Nové hlášení'),
              ),
              Container(
                height: height / 5,
                child: ListView(
                  physics: NeverScrollableScrollPhysics(),
                  padding: const EdgeInsets.all(8.0),
                  children: <Widget>[
                    Text('Fotografie'),
                    ListView.builder(
                      scrollDirection: Axis.horizontal,
                      itemCount: pictures.length,
                      itemBuilder: (BuildContext ctxt, int index) => buildPicture(ctxt, index)
                    ),
                  ],
                ),
              )
            ]
        )

      //Image.file(File(widget.imagePath)),
    );
  }

0 个答案:

没有答案