main.dart

import 'package:flutter/material.dart';
import 'res/listData.dart';
/*
GridView :
通过GridView.count实现网格布局
通过GridView.builder实现网格布局
scrollDirction Axis 滚动方法
padding EdgeInsetsGeometry 内边距
resolve bool 组件反向排序
crossAxisSpacing double 水平子Widget之间间距
mainAxisSpacing double垂直子Widget之间间距
crossAxisCount int 一行的Widget数量
childAspectRatio double 子Wiget宽高比例
*/ void main() {
runApp(MyApp());
} class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
// TODO: implement build
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('GridView'),
),
body: HomeContent(),
),
);
}
} class HomeContent extends StatelessWidget {
//GridView.count
//自定义方法:
// List<Widget> _getListData() {
// // List<Widget> list=new List();
// // for(var i=0;i<20;i++){
// // list.add(Container(
// // alignment: Alignment.center,
// // child: Text(
// // "这是第${i}条数据",
// // style: TextStyle(color: Colors.white,fontSize:20 ),
// // ),
// // color: Colors.blue,
// // ));
// // }
// // return list; // var tempList = listData.map((value) {
// return Container(
// child: Column(
// children: <Widget>[
// Image.network(value['imageUrl']),
// SizedBox(height: 10),
// Text(
// value['title'],
// textAlign: TextAlign.center,
// style: TextStyle(fontSize: 20),
// )
// ],
// ),
// decoration: BoxDecoration(
// border: Border.all(
// color: Color.fromRGBO(233,233,233,0.9),
// width: 1
// )
// ),
// );
// });
// return tempList.toList();
// } // @override
// Widget build(BuildContext context) {
// return GridView.count(
// crossAxisSpacing: 10.0, //水平子Widget之间间距
// mainAxisSpacing: 10.0, //垂直Widget之间的间距
// padding: EdgeInsets.all(10),
// crossAxisCount: 2,
// // childAspectRatio: 0.7, //宽度和高度的比例
// children: this._getListData(),
// );
// } //GridView.builder动态网格; Widget _getListData(context, index) {
return Container(
child: Column(
children: <Widget>[
Image.network(listData[index]['imageUrl']),
SizedBox(height: ),
Text(
listData[index]['title'],
textAlign: TextAlign.center,
style: TextStyle(fontSize: ),
)
],
),
decoration: BoxDecoration(
border:
Border.all(color: Color.fromRGBO(, , , 0.9), width: )),
);
} @override
Widget build(BuildContext context) {
return GridView.builder(
gridDelegate:SliverGridDelegateWithFixedCrossAxisCount(
crossAxisSpacing: 10.0,
mainAxisSpacing: 10.0,
crossAxisCount:
),
itemCount: listData.length,
itemBuilder: this._getListData,
);
}
}

res/listData.dart

List listData=[
{
"title":"Candy Shop",
"author":"Mohamed Chahin",
"imageUrl":"https://www.itying.com/images/flutter/1.png",
},
{
"title":"Candy Shop",
"author":"Mohamed Chahin",
"imageUrl":"https://www.itying.com/images/flutter/2.png",
},
{
"title":"Candy Shop",
"author":"Mohamed Chahin",
"imageUrl":"https://www.itying.com/images/flutter/3.png",
},
{
"title":"Candy Shop",
"author":"Mohamed Chahin",
"imageUrl":"https://www.itying.com/images/flutter/4.png",
},{
"title":"Candy Shop",
"author":"Mohamed Chahin",
"imageUrl":"https://www.itying.com/images/flutter/5.png",
}
];

9Flutter GridView组件 以及动态GridView的更多相关文章

  1. GridView 列表组件 以及动态 GridView

        1.通过 GridView.builder 实现网格布局 Widget getList(context, index) { return Container( margin: EdgeInse ...

  2. Flutter——GridView组件(网格列表组件)

    GridView组件的常用参数: 名称 类型 说明 scrollDirection Axis 滚动方法 padding EdgeInsetsGeometry 内边距 resolve bool 组件反向 ...

  3. 第30讲 UI组件之 GridView组件

    第30讲 UI组件之 GridView组件 1.网格布局组件GridView GridView是一个ViewGroup(布局控件),可使用表格的方式显示组件,可滚动的控件.一般用于显示多张图片,比如实 ...

  4. Flutter中打造多行列列表GridView组件的使用

    GridView组件.一个可滚动的二维空间数组. 在使用无限加载滚动列表的时候,最先使用的还是ListView组件.但若是要一行显示2列或者更多列的滚动列表,GridView组件更为方便.如下 在向服 ...

  5. 安卓开发笔记——GridView组件

    1.什么是GridView? GridView(网格视图)是按照行列的方式来显示内容的,一般用于显示图片,图片等内容,比如实现九宫格图,用GridView是首选,也是最简单的. 2.正文 GridVi ...

  6. Qt Quick 组件和动态创建的对象具体的解释

    在<Qt Quick 事件处理之信号与槽>一文中介绍自己定义信号时,举了一个简单的样例.定义了一个颜色选择组件,当用户在组建内点击鼠标时,该组件会发出一个携带颜色值的信号,当时我使用 Co ...

  7. Vue.js递归组件实现动态树形菜单

    使用Vue递归组件实现动态菜单 现在很多项目的菜单都是动态生成的,之前自己做项目也是遇到这种需求,翻看了官网案例,和网上大神的案例.只有两个感觉,官网的案例太简洁,没有什么注释,看起来不太好理解,大神 ...

  8. Vue组件的操作-自定义组件,动态组件,递归组件

    作者 | Jeskson 来源 | 达达前端小酒馆 v-model双向绑定 创建双向数据绑定,v-model指令用来在input,select,checkbox,radio等表单控件.v-model指 ...

  9. vue组件上动态添加和删除属性

    1.vue组件上动态添加和删除属性 // 添加 this.$set(this.obj, 'propName', val) // 删除 this.$delete(this.obj, 'propName' ...

随机推荐

  1. Flutter——Stack组件(层叠组件)、Align组件、Positioned组件

    Stack 表示堆的意思,我们可以用 Stack 或者 Stack 结合 Align 或者 Stack 结合 Positiond 来实现页面的定位布局. Stack组件 常用于两个子元素. Stack ...

  2. 关于阿里云OSS上传图片之后会被旋转90度的解决办法

    原文:https://www.cnblogs.com/wuhjbk/p/10133596.html 问题描述:正常的图片前端上传到oss成功之后的资源地址.在html上引用的时候被旋转了90度oss资 ...

  3. 用js刷剑指offer(二维数组中的查找)

    题目描述 在一个二维数组中(每个一维数组的长度相同),每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序.请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数 ...

  4. Flyme密码验证策略升级,忘记锁屏密码及「关机密码」功能

      手机里有很多需要用到密码的地方,比如「手机密码」.「文档锁定区」.「应用加密」.「隐私模式」.忘记密码可是一件麻烦事,以前只能通过清除数据或格式化存储盘来解决.现在有了「关联魅族账号」功能,这些功 ...

  5. Ubuntu系统---报错Assertion '0' failed

    Ubuntu系统---报错Assertion '0' failed YOLO V3,CUDA Error: out of memory darknet: ./src/cuda.c:36: check_ ...

  6. 使用raw input 代替全局键盘钩子

    //关于raw input 请查看msdn https://msdn.microsoft.com/en-us/library/windows/desktop/ms645536%28v=vs.85%29 ...

  7. Please, commit your changes or stash them before you can merge. Aborting

    1.stash 通常遇到这个问题,你可以直接commit你的修改:但我这次不想这样. 看看git stash是如何做的. git stash    git pull    git stash pop ...

  8. linux实操_shell运算符

    1."$((运算式))"或"[运算式]" 2.expr m + n 注意:expr运算符要有空格 3.expr m - n 4.expr \*,/,/% 乘,除 ...

  9. JavaScript 基础知识 - BOM篇

    前言 本篇文章是JavaScript基础知识的BOM篇,如果前面的<JavaScript基础知识-DOM篇>看完了,现在就可以学习BOM了. 注意: 所有的案例都在这里链接: 提取密码密码 ...

  10. 后端数据中含有html标签和css样式,前端如何转译展示样式效果。

    后端含有html标签和css样式的数据: domain="<span style='color:red'>www.baidu.com</span>" (vu ...