flutter-GridView网格列表

import 'package:flutter/material.dart';

class MyApp extends StatelessWidget {
  	@override
  	Widget build(BuildContext context) {
    	return MaterialApp(
			title: 'Welcome to Flutter',
			home: Scaffold(
				appBar: AppBar(
					title: Text('Welcome to Flutter'),
				),
				body: GridView(
					// padding: const EdgeInsets.all(20.0),
					gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
						crossAxisCount: 3,	// crossAxisCount:网格的列数 类型int 3列
						mainAxisSpacing: 2.0,	// mainAxisSpacing:垂直间距 类型double
						crossAxisSpacing: 5.0,	// crossAxisSpacing:水平间距 网格间的空隙(相当于外边距)类型double
						childAspectRatio: 1.0,	// childAspectRatio:子Widge宽高比,代表宽是高的多少倍,如果宽是高的2倍,值是2.0,如果高是宽的2倍,值就是0.5。类型double
					),
					children: [
						new Image.network('https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=3791918726,2864900975&fm=26&gp=0.jpg',fit: BoxFit.cover),
						new Image.network('https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=3848402655,92542552&fm=26&gp=0.jpg',fit: BoxFit.cover),
						new Image.network('https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=2370333706,3894132172&fm=26&gp=0.jpg',fit: BoxFit.cover),
						new Image.network('https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2839262297,1897381364&fm=26&gp=0.jpg',fit: BoxFit.cover),
						new Image.network('https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=3895630235,4212690360&fm=26&gp=0.jpg',fit: BoxFit.cover),
					],
				)
			),
    	);
  	}
}

 

 

 

  

 

posted @ 2021-01-26 16:49  江离白芷  阅读(174)  评论(0)    收藏  举报