简体   繁体   中英

How build a listview like this in Flutter?

I created this using two columns and split the list into two parts. But it got so ugly. Any suggestions on how I can create something like this more elegantly?

ListView of cards with differents heights

You can use flutter_staggered_grid_view with QuiltedGridTile

class TAA extends StatelessWidget {
  const TAA({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: GridView.custom(
        gridDelegate: SliverQuiltedGridDelegate(
          crossAxisCount: 2,
          mainAxisSpacing: 4,
          crossAxisSpacing: 4,
          repeatPattern: QuiltedGridRepeatPattern.inverted,
          pattern: [
            QuiltedGridTile(2, 1),
            QuiltedGridTile(1, 1),
          ],
        ),
        childrenDelegate:
            SliverChildBuilderDelegate((context, index) => Container(
                  color: Colors.red,
                )),
      ),
    );
  }
}

在此处输入图像描述

You can decorate the way you want.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM