Flutter GridView的使用

一,效果图在这里插入图片描述
二,看代码

import 'package:flutter/material.dart'; //样式

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return MaterialApp(
      title: '电影海报',
      home: Scaffold(appBar: AppBar(title: Text('电影海报')), body: MyGridView()),
    );
  }
}

class MyGridView extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return GridView(
      gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
          crossAxisCount: 3,//行数
          mainAxisSpacing: 3.0,//内边距
          crossAxisSpacing: 2.0,//间距
          childAspectRatio: 0.7),//设置高度
      children: <Widget>[
        new Image.network(
          'https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=1464869334,620617080&fm=26&gp=0.jpg',
        ),
        new Image.network(
            'https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=1619250361,2440545398&fm=26&gp=0.jpg'),
        new Image.network(
            'https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=808722906,3704058546&fm=26&gp=0.jpg'),
        new Image.network(
            'https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=3762973784,345116142&fm=26&gp=0.jpg'),
        new Image.network(
            'https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=3651815983,2788120398&fm=26&gp=0.jpg'),
        new Image.network(
            'https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=1375636270,3210629340&fm=26&gp=0.jpg'),
        new Image.network(
            'https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=3339348284,2126551996&fm=26&gp=0.jpg'),
        new Image.network(
            'https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=3258865691,3232261264&fm=26&gp=0.jpg'),
        new Image.network(
            'https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=1464869334,620617080&fm=26&gp=0.jpg'),
        new Image.network(
            'https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=3258865691,3232261264&fm=26&gp=0.jpg'),
        new Image.network(
            'https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2878378591,3296449218&fm=26&gp=0.jpg'),
        new Image.network(
            'https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2314304992,841702126&fm=26&gp=0.jpg')
      ],
    );
  }
}

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值