• 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'),
                ),
              ],
            ),
          )
        );
      }
    }


  • 相关阅读:
    jQuery之父:每天都写点代码
    XtraTabControl 控件使用
    Linq:使用Take和Skip实现分页
    WCF教程一之WCF是什么,能做什么
    WCF发布后远程访问的域名解析问题
    C# WinForm下,隐藏主窗体,只在进程管理器中显示进程,在任务栏,状态栏都不显示窗体的方法
    在bat脚本写入中文远行后乱码
    VS2010DebugView捕捉
    Web Service 的工作原理
    String.Format 方法
  • 原文地址:https://www.cnblogs.com/lxz-blogs/p/13225443.html
Copyright © 2020-2023  润新知