Flutter 第1行有2幅图像,第2行有3幅图像使用颤振

Flutter 第1行有2幅图像,第2行有3幅图像使用颤振,flutter,dart,staggered-gridview,Flutter,Dart,Staggered Gridview,如何在有2行的颤振中创建一个交错的视图。在第一行中有两个图像,在第二行中有三个图像,在第二行的最后一个图像中有一些文本,如20+或40+。 为了更好地理解,请看下图 正文:填充( 子:容器 ( 身高:1500, 装饰:盒子装饰( 颜色:颜色,白色, ), 子项:staggedGridView.count( 交叉轴计数:4, 主轴间距:3.0, 交叉轴间距:3.0, 交错文件:[ 交错文件计数(2,1), 交错文件计数(2,1), 交错文件计数(1,1), 交错文件计数(1,1), 交错文件计数

如何在有2行的颤振中创建一个交错的视图。在第一行中有两个图像,在第二行中有三个图像,在第二行的最后一个图像中有一些文本,如20+或40+。
为了更好地理解,请看下图

正文:填充(
子:容器
(
身高:1500,
装饰:盒子装饰(
颜色:颜色,白色,
),
子项:staggedGridView.count(
交叉轴计数:4,
主轴间距:3.0,
交叉轴间距:3.0,
交错文件:[
交错文件计数(2,1),
交错文件计数(2,1),
交错文件计数(1,1),
交错文件计数(1,1),
交错文件计数(1,1),
交错文件计数(1,1),
],
儿童:[
我的照片列表(
"https://www.google.com/search?q=bird&rlz=1C1CHBD_enBD884BD884&sxsrf=ALeKk032QyXLy5s0te6Y52Sp3yyA2g4sfQ:1598990850500&source=lnms&tbm=isch&sa=X&ved=2ahUKEwjslZKN4cjrAhUWWX0KHe3sAdMQ_AUoAXoECB0QAw&biw=1536&bih=792#imgrc=1ois95B-LWBBM”),
我的照片列表(
"https://www.google.com/search?q=bird&rlz=1C1CHBD_enBD884BD884&sxsrf=ALeKk032QyXLy5s0te6Y52Sp3yyA2g4sfQ:1598990850500&source=lnms&tbm=isch&sa=X&ved=2ahUKEwjslZKN4cjrAhUWWX0KHe3sAdMQ_AUoAXoECB0QAw&biw=1536&bih=792#imgrc=1ois95B-LWBBM”),
我的照片列表(
"https://www.google.com/search?q=bird&rlz=1C1CHBD_enBD884BD884&sxsrf=ALeKk032QyXLy5s0te6Y52Sp3yyA2g4sfQ:1598990850500&source=lnms&tbm=isch&sa=X&ved=2ahUKEwjslZKN4cjrAhUWWX0KHe3sAdMQ_AUoAXoECB0QAw&biw=1536&bih=792#imgrc=1ois95B-LWBBM”),
我的照片列表(
"https://www.google.com/search?q=bird&rlz=1C1CHBD_enBD884BD884&sxsrf=ALeKk032QyXLy5s0te6Y52Sp3yyA2g4sfQ:1598990850500&source=lnms&tbm=isch&sa=X&ved=2ahUKEwjslZKN4cjrAhUWWX0KHe3sAdMQ_AUoAXoECB0QAw&biw=1536&bih=792#imgrc=1ois95B-LWBBM”),
我的照片列表(
"https://www.google.com/search?q=bird&rlz=1C1CHBD_enBD884BD884&sxsrf=ALeKk032QyXLy5s0te6Y52Sp3yyA2g4sfQ:1598990850500&source=lnms&tbm=isch&sa=X&ved=2ahUKEwjslZKN4cjrAhUWWX0KHe3sAdMQ_AUoAXoECB0QAw&biw=1536&bih=792#imgrc=1ois95B-LWBBM”),
我的照片列表(
"https://www.google.com/search?q=bird&rlz=1C1CHBD_enBD884BD884&sxsrf=ALeKk032QyXLy5s0te6Y52Sp3yyA2g4sfQ:1598990850500&source=lnms&tbm=isch&sa=X&ved=2ahUKEwjslZKN4cjrAhUWWX0KHe3sAdMQ_AUoAXoECB0QAw&biw=1536&bih=792#imgrc=1ois95B-LWBBM”),
详细信息(),
],
),
),
),
小部件myPhotoList(字符串img){
返回容器(
装饰:盒子装饰(
图像:装饰图像(
fit:BoxFit.fill,
图片:NetworkImage(
img),
),
),
);
}

你在找这个吗

body: Container(
        height: 1500,
        decoration: BoxDecoration(
          color: Colors.white,
        ),
        child: StaggeredGridView.count(
          crossAxisCount: 6,
          mainAxisSpacing: 3.0,
          crossAxisSpacing: 3.0,
          staggeredTiles: [
            StaggeredTile.count(3, 2),
            StaggeredTile.count(3, 2),
            StaggeredTile.count(2, 2),
            StaggeredTile.count(2, 2),
            StaggeredTile.count(2, 2),
            // StaggeredTile.count(1, 1),
          ],
          children: <Widget>[
            myPhotoList(
                "https://www.google.com/search?q=bird&rlz=1C1CHBD_enBD884BD884&sxsrf=ALeKk032QyXLy5s0te6Y52Sp3yyA2g4sfQ:1598990850500&source=lnms&tbm=isch&sa=X&ved=2ahUKEwjslZKN4cjrAhUWWX0KHe3sAdMQ_AUoAXoECB0QAw&biw=1536&bih=792#imgrc=1ois95B-LwbEBM"),
            myPhotoList(
                "https://www.google.com/search?q=bird&rlz=1C1CHBD_enBD884BD884&sxsrf=ALeKk032QyXLy5s0te6Y52Sp3yyA2g4sfQ:1598990850500&source=lnms&tbm=isch&sa=X&ved=2ahUKEwjslZKN4cjrAhUWWX0KHe3sAdMQ_AUoAXoECB0QAw&biw=1536&bih=792#imgrc=1ois95B-LwbEBM"),
            myPhotoList(
                "https://www.google.com/search?q=bird&rlz=1C1CHBD_enBD884BD884&sxsrf=ALeKk032QyXLy5s0te6Y52Sp3yyA2g4sfQ:1598990850500&source=lnms&tbm=isch&sa=X&ved=2ahUKEwjslZKN4cjrAhUWWX0KHe3sAdMQ_AUoAXoECB0QAw&biw=1536&bih=792#imgrc=1ois95B-LwbEBM"),
            myPhotoList(
                "https://www.google.com/search?q=bird&rlz=1C1CHBD_enBD884BD884&sxsrf=ALeKk032QyXLy5s0te6Y52Sp3yyA2g4sfQ:1598990850500&source=lnms&tbm=isch&sa=X&ved=2ahUKEwjslZKN4cjrAhUWWX0KHe3sAdMQ_AUoAXoECB0QAw&biw=1536&bih=792#imgrc=1ois95B-LwbEBM"),
            myPhotoList(
                "https://www.google.com/search?q=bird&rlz=1C1CHBD_enBD884BD884&sxsrf=ALeKk032QyXLy5s0te6Y52Sp3yyA2g4sfQ:1598990850500&source=lnms&tbm=isch&sa=X&ved=2ahUKEwjslZKN4cjrAhUWWX0KHe3sAdMQ_AUoAXoECB0QAw&biw=1536&bih=792#imgrc=1ois95B-LwbEBM"),
            //myPhotoList(
            //  "https://www.google.com/search?q=bird&rlz=1C1CHBD_enBD884BD884&sxsrf=ALeKk032QyXLy5s0te6Y52Sp3yyA2g4sfQ:1598990850500&source=lnms&tbm=isch&sa=X&ved=2ahUKEwjslZKN4cjrAhUWWX0KHe3sAdMQ_AUoAXoECB0QAw&biw=1536&bih=792#imgrc=1ois95B-LwbEBM"),
          ],
        ),
      ),
主体:容器(
身高:1500,
装饰:盒子装饰(
颜色:颜色,白色,
),
子项:staggedGridView.count(
交叉轴计数:6,
主轴间距:3.0,
交叉轴间距:3.0,
交错文件:[
交错文件计数(3,2),
交错文件计数(3,2),
交错文件计数(2,2),
交错文件计数(2,2),
交错文件计数(2,2),
//交错文件计数(1,1),
],
儿童:[
我的照片列表(
"https://www.google.com/search?q=bird&rlz=1C1CHBD_enBD884BD884&sxsrf=ALeKk032QyXLy5s0te6Y52Sp3yyA2g4sfQ:1598990850500&source=lnms&tbm=isch&sa=X&ved=2ahUKEwjslZKN4cjrAhUWWX0KHe3sAdMQ_AUoAXoECB0QAw&biw=1536&bih=792#imgrc=1ois95B-LWBBM”),
我的照片列表(
"https://www.google.com/search?q=bird&rlz=1C1CHBD_enBD884BD884&sxsrf=ALeKk032QyXLy5s0te6Y52Sp3yyA2g4sfQ:1598990850500&source=lnms&tbm=isch&sa=X&ved=2ahUKEwjslZKN4cjrAhUWWX0KHe3sAdMQ_AUoAXoECB0QAw&biw=1536&bih=792#imgrc=1ois95B-LWBBM”),
我的照片列表(
"https://www.google.com/search?q=bird&rlz=1C1CHBD_enBD884BD884&sxsrf=ALeKk032QyXLy5s0te6Y52Sp3yyA2g4sfQ:1598990850500&source=lnms&tbm=isch&sa=X&ved=2ahUKEwjslZKN4cjrAhUWWX0KHe3sAdMQ_AUoAXoECB0QAw&biw=1536&bih=792#imgrc=1ois95B-LWBBM”),
我的照片列表(
"https://www.google.com/search?q=bird&rlz=1C1CHBD_enBD884BD884&sxsrf=ALeKk032QyXLy5s0te6Y52Sp3yyA2g4sfQ:1598990850500&source=lnms&tbm=isch&sa=X&ved=2ahUKEwjslZKN4cjrAhUWWX0KHe3sAdMQ_AUoAXoECB0QAw&biw=1536&bih=792#imgrc=1ois95B-LWBBM”),
我的照片列表(
"https://www.google.com/search?q=bird&rlz=1C1CHBD_enBD884BD884&sxsrf=ALeKk032QyXLy5s0te6Y52Sp3yyA2g4sfQ:1598990850500&source=lnms&tbm=isch&sa=X&ved=2ahUKEwjslZKN4cjrAhUWWX0KHe3sAdMQ_AUoAXoECB0QAw&biw=1536&bih=792#imgrc=1ois95B-LWBBM”),
//我的照片列表(
//  "https://www.google.com/search?q=bird&rlz=1C1CHBD_enBD884BD884&sxsrf=ALeKk032QyXLy5s0te6Y52Sp3yyA2g4sfQ:1598990850500&source=lnms&tbm=isch&sa=X&ved=2ahUKEwjslZKN4cjrAhUWWX0KHe3sAdMQ_AUoAXoECB0QAw&biw=1536&bih=792#imgrc=1ois95B-LWBBM”),
],
),
),

如果你添加一些你尝试过的鼓励社区回答的代码,那就太棒了,无论如何,我会尝试为YouTunks做些事情。我添加了一些代码。这样,我在第一行添加了2个图像,在第二行添加了4个图像。但未能在第二行中添加3个图像,而不是4个图像。pub.dev上此插件的定义是“一个颤振交错网格视图,支持多个列,行大小不同”。然而,您需要非常静态和预定义的内容(第一行=2列,第二行=3列)。因此,对于您来说,最好的解决方案不是让
staggeredGridView
符合您的特定需求,而是改变您正在使用的工具
body: Container(
        height: 1500,
        decoration: BoxDecoration(
          color: Colors.white,
        ),
        child: StaggeredGridView.count(
          crossAxisCount: 6,
          mainAxisSpacing: 3.0,
          crossAxisSpacing: 3.0,
          staggeredTiles: [
            StaggeredTile.count(3, 2),
            StaggeredTile.count(3, 2),
            StaggeredTile.count(2, 2),
            StaggeredTile.count(2, 2),
            StaggeredTile.count(2, 2),
            // StaggeredTile.count(1, 1),
          ],
          children: <Widget>[
            myPhotoList(
                "https://www.google.com/search?q=bird&rlz=1C1CHBD_enBD884BD884&sxsrf=ALeKk032QyXLy5s0te6Y52Sp3yyA2g4sfQ:1598990850500&source=lnms&tbm=isch&sa=X&ved=2ahUKEwjslZKN4cjrAhUWWX0KHe3sAdMQ_AUoAXoECB0QAw&biw=1536&bih=792#imgrc=1ois95B-LwbEBM"),
            myPhotoList(
                "https://www.google.com/search?q=bird&rlz=1C1CHBD_enBD884BD884&sxsrf=ALeKk032QyXLy5s0te6Y52Sp3yyA2g4sfQ:1598990850500&source=lnms&tbm=isch&sa=X&ved=2ahUKEwjslZKN4cjrAhUWWX0KHe3sAdMQ_AUoAXoECB0QAw&biw=1536&bih=792#imgrc=1ois95B-LwbEBM"),
            myPhotoList(
                "https://www.google.com/search?q=bird&rlz=1C1CHBD_enBD884BD884&sxsrf=ALeKk032QyXLy5s0te6Y52Sp3yyA2g4sfQ:1598990850500&source=lnms&tbm=isch&sa=X&ved=2ahUKEwjslZKN4cjrAhUWWX0KHe3sAdMQ_AUoAXoECB0QAw&biw=1536&bih=792#imgrc=1ois95B-LwbEBM"),
            myPhotoList(
                "https://www.google.com/search?q=bird&rlz=1C1CHBD_enBD884BD884&sxsrf=ALeKk032QyXLy5s0te6Y52Sp3yyA2g4sfQ:1598990850500&source=lnms&tbm=isch&sa=X&ved=2ahUKEwjslZKN4cjrAhUWWX0KHe3sAdMQ_AUoAXoECB0QAw&biw=1536&bih=792#imgrc=1ois95B-LwbEBM"),
            myPhotoList(
                "https://www.google.com/search?q=bird&rlz=1C1CHBD_enBD884BD884&sxsrf=ALeKk032QyXLy5s0te6Y52Sp3yyA2g4sfQ:1598990850500&source=lnms&tbm=isch&sa=X&ved=2ahUKEwjslZKN4cjrAhUWWX0KHe3sAdMQ_AUoAXoECB0QAw&biw=1536&bih=792#imgrc=1ois95B-LwbEBM"),
            //myPhotoList(
            //  "https://www.google.com/search?q=bird&rlz=1C1CHBD_enBD884BD884&sxsrf=ALeKk032QyXLy5s0te6Y52Sp3yyA2g4sfQ:1598990850500&source=lnms&tbm=isch&sa=X&ved=2ahUKEwjslZKN4cjrAhUWWX0KHe3sAdMQ_AUoAXoECB0QAw&biw=1536&bih=792#imgrc=1ois95B-LwbEBM"),
          ],
        ),
      ),