我正试着布置一个4x4的瓷砖网格.我设法用列和行做到了这一点.但现在我找到了GridView的分量.有没有人能举例说明如何使用它?

我真的不能把我的头放在doctor 身上.我似乎没有得到我想要的结果.

推荐答案

这是一个将图像加载到瓷砖中的简单示例.

import 'package:flutter/material.dart';

void main() {
  runApp( MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(

      color: Colors.white30,
      child: GridView.count(
          crossAxisCount: 4,
          childAspectRatio: 1.0,
          padding: const EdgeInsets.all(4.0),
          mainAxisSpacing: 4.0,
          crossAxisSpacing: 4.0,
          children: <String>[
            'http://www.for-example.org/img/main/forexamplelogo.png',
            'http://www.for-example.org/img/main/forexamplelogo.png',
            'http://www.for-example.org/img/main/forexamplelogo.png',
            'http://www.for-example.org/img/main/forexamplelogo.png',
            'http://www.for-example.org/img/main/forexamplelogo.png',
            'http://www.for-example.org/img/main/forexamplelogo.png',
            'http://www.for-example.org/img/main/forexamplelogo.png',
            'http://www.for-example.org/img/main/forexamplelogo.png',
            'http://www.for-example.org/img/main/forexamplelogo.png',
            'http://www.for-example.org/img/main/forexamplelogo.png',
            'http://www.for-example.org/img/main/forexamplelogo.png',
          ].map((String url) {
            return GridTile(
                child: Image.network(url, fit: BoxFit.cover));
          }).toList()),
    );
  }
}

Flutter gallery 应用程序包含一个真实世界的示例,可以找到here个.

enter image description here

Flutter相关问答推荐

SingleChildScrollView正在将Container的高度限制为子对象,尽管使用了Expanded Inside Row()

我如何才能动态地将小部件排成一排进行排列呢?

悬停时打开Flutter 下拉按钮

有没有什么方法可以加快在Flutter 中加载Quill HTML编辑器的速度?

我有相关的下拉菜单Flutter Windows应用程序的问题

如何使用flutter_local_notification包处理通知操作?

在Ffltter中,我已经使用了Ffltter_BLOC Cupit和Pusher,但当获得新数据时,UI没有更新

播放特定持续时间Flutter 的音频

如何在 Flutter 中以背景 colored颜色 制作圆圈的一部分

无法从一个页面导航到下一个页面 (Flutter)

Flutter如何在容器外创建环形进度条

Flutter ImagePicker - 在 onPressed 中异步获取图像显示 lint 警告

更改 flutter listview 中的布局

状况不佳 - Cubit

alert 对话框内的 ListView 显示空的透明窗口

Getx Flutter 在更新值时抛出空错误

我可以使用 Future 来填充Text() 小部件而不是在 Flutter 中使用 FutureBuilder 吗?

Positioned 的宽度或 SizedBox 的宽度都不适用于堆栈小部件 - Flutter

在 Flutter 中更新对象实例属性的最佳实践是什么?该实例嵌套在提供程序类的映射中,如下所示

如何从圆角go 除背景 colored颜色