当前位置:网站首页>Flutter series part: detailed explanation of GridView layout commonly used in flutter
Flutter series part: detailed explanation of GridView layout commonly used in flutter
2022-06-12 22:14:00 【InfoQ】
brief introduction
GridView Detailed explanation
class GridView extends BoxScrollView
abstract class BoxScrollView extends ScrollView
@override
Widget buildChildLayout(BuildContext context) {
return SliverGrid(
delegate: childrenDelegate,
gridDelegate: gridDelegate,
);
}
GridView Constructor for
GridView({
Key? key,
Axis scrollDirection = Axis.vertical,
bool reverse = false,
ScrollController? controller,
bool? primary,
ScrollPhysics? physics,
bool shrinkWrap = false,
EdgeInsetsGeometry? padding,
required this.gridDelegate,
bool addAutomaticKeepAlives = true,
bool addRepaintBoundaries = true,
bool addSemanticIndexes = true,
double? cacheExtent,
List<Widget> children = const <Widget>[],
int? semanticChildCount,
DragStartBehavior dragStartBehavior = DragStartBehavior.start,
Clip clipBehavior = Clip.hardEdge,
ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual,
String? restorationId,
})
required this.gridDelegate
childrenDelegate = SliverChildListDelegate(
children,
addAutomaticKeepAlives: addAutomaticKeepAlives,
addRepaintBoundaries: addRepaintBoundaries,
addSemanticIndexes: addSemanticIndexes,
),
childrenDelegate = SliverChildBuilderDelegate(
itemBuilder,
childCount: itemCount,
addAutomaticKeepAlives: addAutomaticKeepAlives,
addRepaintBoundaries: addRepaintBoundaries,
addSemanticIndexes: addSemanticIndexes,
),
required this.gridDelegate,
required this.childrenDelegate
gridDelegate = SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: crossAxisCount,
mainAxisSpacing: mainAxisSpacing,
crossAxisSpacing: crossAxisSpacing,
childAspectRatio: childAspectRatio,
),
gridDelegate = SliverGridDelegateWithMaxCrossAxisExtent(
maxCrossAxisExtent: maxCrossAxisExtent,
mainAxisSpacing: mainAxisSpacing,
crossAxisSpacing: crossAxisSpacing,
childAspectRatio: childAspectRatio,
),
GridView Use
class GridViewApp extends StatelessWidget{
@override
Widget build(BuildContext context) {
return GridView.extent(
maxCrossAxisExtent: 100,
padding: const EdgeInsets.all(4),
mainAxisSpacing: 4,
crossAxisSpacing: 4,
children: buildChild(10));
}
List<Widget> buildChild(int number) {
return List.generate(
number, (i) => Container(
child: Image.asset('images/head.jpg')));
}
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: GridViewApp(),
),
);
}

summary
边栏推荐
- [Jianzhi offer] Jianzhi offer 09 Implementing queues with two stacks
- 【QNX Hypervisor 2.2 用户手册】4.4 构建Host
- Use group_ Dplyr issues when using group_ by(multiple variables)
- MySQL体系结构及基础管理(二)
- 【图像去噪】基于三边滤波器实现图像去噪附matlab代码
- 【QNX Hypervisor 2.2 用户手册】4.2 支持的构建环境
- IPhone: save Boolean into core data - iphone: save Boolean into core data
- Dolphin-2.0.3 cluster deployment document
- talent showing itself! Oceanbase was selected into the 2021 "sci tech innovation China" open source innovation list
- Pat grade A - 1167 Cartesian tree (30 points) (buildtree + level traversal)
猜你喜欢

Design a MySQL table for message queue to store message data

【数据分析】基于 kmeans实现数据聚类分组含Matlab源码

Jin AI her power | impact tech, she can

SQL tuning guide notes 13:gathering optimizer statistics

leetcodeSQL:574. Elected

Ansible playbook and ansible roles (III)

How to perform disaster recovery and recovery for kubernetes cluster? (22)
![[image denoising] image denoising based on trilateral filter with matlab code](/img/f2/770a0e2938728e731c18c0a66f7c12.png)
[image denoising] image denoising based on trilateral filter with matlab code

Open source background management system suitable for outsourcing projects

SQL tuning guide notes 8:optimizer access paths
随机推荐
六月集训(第11天) —— 矩阵
Database daily question --- day 10: combine two tables
Is it safe to open an account with new bonds? How should novices operate?
The interface testing tool apipos3.0 is applicable to process testing and reference parameter variables
【Proteus仿真】简易数码管定时器时钟
(downloadable) Research Report on the development and utilization of government data (2021), a glimpse of the development of Government Office
How to develop programming learning with zero foundation during college
JVM Basics - > how GC determines that an object can be recycled
LNMP platform docking redis service
Ansible playbook和Ansible Roles(三)
动态规划之如何将问题抽象转化为0-1背包问题(详解利用动态规划求方案数)
SQL tuning guide notes 9:joins
Qt Quick 3D学习:使用鼠标键盘控制节点位置和方向
Ansible foundation and common modules (I)
What is the difference between volatile variables and atomic variables?
How to write a vscode plug-in by yourself to realize plug-in freedom!
JVM Basics - > how to troubleshoot JVM problems in your project
C#读取word中表格数据
[Jianzhi offer] Jianzhi offer 09 Implementing queues with two stacks
Build a highly available database