第一种

  1. import 'package:flutter/material.dart';
  2. void main() => runApp(MyApp());
  3. class MyApp extends StatelessWidget {
  4. // This widget is the root of your application.
  5. @override
  6. Widget build(BuildContext context) {
  7. return MaterialApp(
  8. title: 'Flutter Demo',
  9. theme: ThemeData(
  10. primarySwatch: Colors.blue,
  11. ),
  12. home: Scaffold(
  13. appBar: new AppBar(title: new Text ('mystudys')),
  14. body: GridView.count(
  15. padding: const EdgeInsets.all(20.0), //页面外边距
  16. crossAxisSpacing:10.0, //网格边距
  17. crossAxisCount: 3, // 一行显示多少列
  18. children: <Widget>[
  19. const Text('i love ncuhome'),
  20. const Text('i love running'),
  21. const Text('i love running'),
  22. const Text('i love ncuhome'),
  23. const Text('i love running'),
  24. const Text('i love running'),
  25. const Text('i love ncuhome'),
  26. const Text('i love running'),
  27. const Text('i love running'),
  28. ],
  29. )
  30. ),
  31. );
  32. }
  33. }

第二种

  1. import 'package:flutter/material.dart';
  2. void main() => runApp(MyApp());
  3. class MyApp extends StatelessWidget {
  4. // This widget is the root of your application.
  5. @override
  6. Widget build(BuildContext context) {
  7. return MaterialApp(
  8. title: 'Flutter Demo',
  9. theme: ThemeData(
  10. primarySwatch: Colors.blue,
  11. ),
  12. home: Scaffold(
  13. appBar: new AppBar(title: new Text ('mystudys')),
  14. body: GridView(
  15. gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  16. crossAxisCount: 3,//一行展示个数
  17. mainAxisSpacing: 4.0,//行间距
  18. crossAxisSpacing: 2.0,//列间距
  19. childAspectRatio: 0.8// 横竖比
  20. ),
  21. children: <Widget>[
  22. new Image.network('https://ss2.baidu.com/6ONYsjip0QIZ8tyhnq/it/u=2399609660,3433792887&fm=58&s=BEB5B0AE44339FF9062DEE8C03008087', fit: BoxFit.cover,),
  23. new Image.network('https://ss1.baidu.com/6ONXsjip0QIZ8tyhnq/it/u=3921574999,1717079445&fm=58&s=19C8EF5D8F426E4D18C824780300807E', fit: BoxFit.cover,),
  24. new Image.network('https://ss2.baidu.com/6ONYsjip0QIZ8tyhnq/it/u=3640626071,901694792&fm=58&s=03F05A906A197EC45C9D4D51030070E2', fit: BoxFit.cover,),
  25. new Image.network('https://ss2.baidu.com/6ONYsjip0QIZ8tyhnq/it/u=1138506920,2521439042&fm=58&s=251E3FD7F8D133F91EBC977B03003064', fit: BoxFit.cover,),
  26. new Image.network('https://ss2.baidu.com/6ONYsjip0QIZ8tyhnq/it/u=3640626071,901694792&fm=58&s=03F05A906A197EC45C9D4D51030070E2', fit: BoxFit.cover,),
  27. new Image.network('https://ss0.baidu.com/6ONWsjip0QIZ8tyhnq/it/u=3197691219,1079587509&fm=58&s=4D1E5C9B189A1FE97A1CF4CF03007033', fit: BoxFit.cover,),
  28. new Image.network('https://ss2.baidu.com/6ONYsjip0QIZ8tyhnq/it/u=3259142462,2413291210&fm=58&s=EC2000D610DF37FFCD009112030060D3', fit: BoxFit.cover,),
  29. new Image.network('https://ss2.baidu.com/6ONYsjip0QIZ8tyhnq/it/u=3640626071,901694792&fm=58&s=03F05A906A197EC45C9D4D51030070E2', fit: BoxFit.cover,),
  30. new Image.network('https://ss2.baidu.com/6ONYsjip0QIZ8tyhnq/it/u=3640626071,901694792&fm=58&s=03F05A906A197EC45C9D4D51030070E2', fit: BoxFit.cover,),
  31. ],
  32. )
  33. )
  34. );
  35. }
  36. }

image.png