Flutter-如何缩小列表视图项目的宽度

问题描述 投票:0回答:1

尽管我有一些Android开发经验,但我还是很陌生。我正在尝试创建一个混乱的页面,该页面需要用Google地图覆盖整个页面,并且最上面需要显示图像列表。

我能够通过堆栈对象实现这一点,但是不幸的是,图像列表覆盖了整个宽度,所有触摸都移到了列表中,而不是在地图上。

这是我的代码

@override
  Widget build(BuildContext context) {
    return SafeArea(
      child: new Scaffold(
          appBar: new AppBar(
            title: new Text("Tracker"),
            backgroundColor: Colors.blueAccent,
          ),
          drawer: Drawer(child: DrawerLayout()),
          body: _buildBody()),
    );
  }

  Widget _buildBody() {
    return Stack(children: <Widget>[
      _buildMap(),
      _buildImages(),
    ]);
  }

may maps widgets is this

Widget _buildMap() {
    return GoogleMap(
      onMapCreated: _onMapCreated,
      markers: _markers,
      myLocationEnabled: true,
      compassEnabled: true,
      initialCameraPosition: CameraPosition(
        target: _center,
        zoom: 15.0,
      ),
    );
  }

这是我的小部件,用于将图像加载到屏幕的右侧(不幸的是,它不会缩小宽度),而是覆盖了整个宽度

Widget _buildImages() {
    return ListView.builder(
        itemCount: _images.length + 1,
        itemBuilder: (_, int index) {
            profile = _images[index]
            return new Container(
              child: Align(
                alignment: Alignment.topRight,
                child: FloatingActionButton(
                  mini: true,
                  materialTapTargetSize: MaterialTapTargetSize.padded,
                  child: _loadProfileImage(profile),
                ),
              ),
            );
        });
  }

我在地图顶部显示图像没有问题,但问题是它需要整个宽度。

我想做几件事:

  1. 在地图顶部显示图像,但将宽度包装为固定大小
  2. 并排显示地图和图像,但要使地图占用尽可能多的空间。
  3. enter image description here

向我的列表视图项目中添加背景色以表明它实际上占据了整个宽度,有没有办法我可以包裹那个宽度?

enter image description here

尽管我有一些Android开发经验,但我还是很陌生。我正在尝试创建一个混乱的页面,我需要用Google地图覆盖整个页面,并在其中一个页面之上...

flutter flutter-layout
1个回答
1
投票

您可以使用SizedBox包裹ListView并设置其宽度:

© www.soinside.com 2019 - 2024. All rights reserved.