写了个flutter demo,直接copy到入口函数:

legs+之专栏 legs+之专栏 1242 人阅读 | 2 人回复 | 2022-07-25

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

x
360截图20220725171500929.jpg










  1. import 'package:flutter/material.dart';

  2. // void main() => runApp(MyApp());

  3. void main(){
  4.   runApp(MyApp());
  5. }
  6. class MyApp extends StatelessWidget {
  7.   @override
  8.   Widget build(BuildContext context) {
  9.     return MaterialApp(
  10.         title: 'Welcome to Flutter',
  11.         home: Scaffold(
  12.             appBar: AppBar(
  13.               title: Text('Grid表格布局'),
  14.             ),
  15.             body: GridView.count(
  16.               crossAxisCount: 2,
  17.               crossAxisSpacing: 2,
  18.               mainAxisSpacing: 2,
  19.               childAspectRatio: 1,
  20.               // padding: const EdgeInsets.all(20),
  21.               children: [
  22.                 Image.network('http://img5.mtime.cn/mg/2021/08/24/141454.81651527_285X160X4.jpg',fit: BoxFit.cover,),
  23.                 Image.network('http://img5.mtime.cn/mg/2021/08/24/134535.67957178_285X160X4.jpg',fit: BoxFit.cover,),
  24.                 Image.network('http://img5.mtime.cn/mg/2021/08/24/112722.60735295_285X160X4.jpg',fit: BoxFit.cover,),
  25.                 Image.network('http://img5.mtime.cn/mg/2021/08/24/110937.63038065_285X160X4.jpg',fit: BoxFit.cover,),
  26.                 Image.network('http://img5.mtime.cn/mg/2021/08/24/101606.96675436_285X160X4.jpg',fit: BoxFit.cover,),
  27.                 Image.network('http://img5.mtime.cn/mg/2021/08/24/094036.69360356_285X160X4.jpg',fit: BoxFit.cover,),
  28.                 Image.network('http://img5.mtime.cn/mg/2021/08/24/093233.40634890_285X160X4.jpg',fit: BoxFit.cover,),
  29.                 Image.network('http://img5.mtime.cn/mg/2021/08/24/090626.28438629_285X160X4.jpg',fit: BoxFit.cover,),
  30.               ],
  31.             )));
  32.   }
  33. }
复制代码


回答|共 2 个

legs+ 发表于 2022-7-25 17:22:36| 字数 47 | 显示全部楼层

Enter these two commands Flutter Pub get and Flutter Run

孤星1 发表于 2022-7-27 20:45:07| 字数 45 | 显示全部楼层

厉害!只可惜删了我的Android Studio和Flutter,不然可以复制代码测试一下。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

热门推荐