Flutter开发(六)—— GridView网格列表

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/RedKeyer/article/details/89551660

展示效果:

在这里插入图片描述

上图对应代码:

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return MaterialApp(
      title: "List",
      home: Scaffold(
          appBar: new AppBar(
            title: new Text("GridView"),
          ),
          body: GridView(
            gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
              crossAxisCount: 2, //每行的列数
              childAspectRatio: 1.0, //  宽/高=2.0 宽高比
              mainAxisSpacing: 3.0, // item之间的间距 y方向
              crossAxisSpacing: 3.0, // item之间的间距 x方向
            ),
            children: <Widget>[
              new Image.network(
                "https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=1094652878,2903810746&fm=26&gp=0.jpg",
                fit: BoxFit.cover,
              ),
              new Image.network(
                  "https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=3194365855,1891901271&fm=26&gp=0.jpg",
                  fit: BoxFit.cover),
              new Image.network(
                  "https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2588002001,3596323075&fm=26&gp=0.jpg",
                  fit: BoxFit.cover),
              new Image.network(
                  "https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1593456909,670174312&fm=26&gp=0.jpg",
                  fit: BoxFit.cover),
            ],
          )),
    );
  }
}

上面测试时,发现一个问题:
图片为http时,Android8.0不能正常加载。我对Android进行清单文件配置,试图让其不检测https。但是貌似没有效果,这里记录下!

猜你喜欢

转载自blog.csdn.net/RedKeyer/article/details/89551660