zoukankan      html  css  js  c++  java
  • flutter-GridView(网格列表)

    import 'package:flutter/material.dart';
    
    void main ()=> runApp(MyApp());
    
    class MyApp extends StatelessWidget{
      @override
      Widget build(BuildContext context){
        return MaterialApp(
          title:"Grid",
          home:Scaffold(
            appBar: AppBar(
              title:Text('Grid')
            ),
            // body:GridView.count(
            //   padding: const EdgeInsets.all(0.0),
            //   // 每行几个
            //   crossAxisCount: 3,
            //   //网格间距离
            //   crossAxisSpacing: 10.0,
            //   children: <Widget>[
            //     Icon(Icons.ac_unit),
            //     Icon(Icons.airport_shuttle),
            //     Icon(Icons.all_inclusive),
            //     Icon(Icons.beach_access),
            //     Icon(Icons.cake),
            //     Icon(Icons.free_breakfast),
            //   ],
            // )
            body: GridView(
              gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                crossAxisCount: 3,
                mainAxisSpacing: 2.0,
                crossAxisSpacing: 2.0,
                //宽度和高度比
                childAspectRatio: 1,
              ),
              children: <Widget>[
                Image(
                  image: AssetImage('images/2222.png'),
                  fit: BoxFit.cover,
                ),
                Image(
                  image: AssetImage('images/2222.png'),
                ),
                Image(
                  image: AssetImage('images/2222.png'),
                ),
                Image(
                  image: AssetImage('images/2222.png'),
                ),
                Image(
                  image: AssetImage('images/2222.png'),
                ),
                Image(
                  image: AssetImage('images/2222.png'),
                ),
              ],
            ),
          )
        );
      }
    }
    import 'package:flutter/material.dart';

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

    class MyApp extends StatelessWidget{
      @override
      Widget build(BuildContext context){
        return MaterialApp(
          title:"Grid",
          home:Scaffold(
            appBar: AppBar(
              title:Text('Grid')
            ),
            // body:GridView.count(
            //   padding: const EdgeInsets.all(0.0),
            //   // 每行几个
            //   crossAxisCount: 3,
            //   //网格间距离
            //   crossAxisSpacing: 10.0,
            //   children: <Widget>[
            //     Icon(Icons.ac_unit),
            //     Icon(Icons.airport_shuttle),
            //     Icon(Icons.all_inclusive),
            //     Icon(Icons.beach_access),
            //     Icon(Icons.cake),
            //     Icon(Icons.free_breakfast),
            //   ],
            // )
            body: GridView(
              gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                crossAxisCount: 3,
                mainAxisSpacing: 2.0,
                crossAxisSpacing: 2.0,
                //宽度和高度比
                childAspectRatio: 1,
              ),
              children: <Widget>[
                Image(
                  image: AssetImage('images/2222.png'),
                  fit: BoxFit.cover,
                ),
                Image(
                  image: AssetImage('images/2222.png'),
                ),
                Image(
                  image: AssetImage('images/2222.png'),
                ),
                Image(
                  image: AssetImage('images/2222.png'),
                ),
                Image(
                  image: AssetImage('images/2222.png'),
                ),
                Image(
                  image: AssetImage('images/2222.png'),
                ),
              ],
            ),
          )
        );
      }
    }


  • 相关阅读:
    快速导出B站收藏单节目列表
    打包Python程序
    PHP应用日志记录
    这几天折腾win10访问deepin共享的历程
    PHP更新本地公网IP到阿里云域名解析,实现DDNS
    PHP.ini 能不能加载子配置文件 ?
    PHP处理表单数据的一个安全回顾(记录教训)
    不用U盘,用一台好电脑给另一个电脑重装windows10
    方正 ignb路由器设置备份(自用笔记)
    Xiuno BBS 4.0 修改时间显示
  • 原文地址:https://www.cnblogs.com/lxz-blogs/p/13225443.html
Copyright © 2011-2022 走看看