zoukankan      html  css  js  c++  java
  • Flutter学习之ListView(1)

    import 'package:flutter/material.dart';
    
    void main() => runApp(MyApp());
    
    class MyApp extends StatelessWidget{
      @override
      Widget build(BuildContext context){
        return MaterialApp(
          title: "Flutter Demo",
          home: Scaffold(
            appBar: new AppBar(
              title: new Text("listview"),
              backgroundColor: Colors.pinkAccent,
            ),
            body: Center(
              child: new ListView(
                children: <Widget>[
                  new ListTile(
                    leading: new Icon(Icons.perm_camera_mic),
                    title: new Text("perm_camera_mic"),
                  ),
                  new ListTile(
                    leading: new Icon(Icons.perm_contact_calendar),
                    title: new Text("perm_contact_calendar"),
                  ),
                  new ListTile(
                    leading: new Icon(Icons.place),
                    title: new Text("place"),
                  ),
                  new Image.network("https://i2.hdslb.com/bfs/archive/0bf607f90c77f79ca2b1b461ff5096826ac6ce66.jpg@336w_190h.webp"),
                  new Image.network("https://i2.hdslb.com/bfs/archive/0bf607f90c77f79ca2b1b461ff5096826ac6ce66.jpg@336w_190h.webp"),
                  new Image.network("https://i2.hdslb.com/bfs/archive/0bf607f90c77f79ca2b1b461ff5096826ac6ce66.jpg@336w_190h.webp"),
                  new Image.network("https://i2.hdslb.com/bfs/archive/0bf607f90c77f79ca2b1b461ff5096826ac6ce66.jpg@336w_190h.webp")
                ],
              ),
              ),
            ),
          );
      }
    }
    

    这段代码和之前文章里的代码除了ListView组件不同以外,在home: Scaffold()这一层里又加了 一个AppBar组件,在里面设置了title属性。

    这里在body里加了ListView组件,并设置了

    children: <Widget>[
                  new ListTile(
                    leading: new Icon(Icons.perm_camera_mic),  //一个图标,使用Icon组件
                    title: new Text("perm_camera_mic"),
                  ),
                  new ListTile(
                    leading: new Icon(Icons.perm_contact_calendar),
                    title: new Text("perm_contact_calendar"),
                  ),
                  new ListTile(
                    leading: new Icon(Icons.place),
                    title: new Text("place"),
                  ),
                  new Image.network("https://i2.hdslb.com/bfs/archive/0bf607f90c77f79ca2b1b461ff5096826ac6ce66.jpg@336w_190h.webp"),
                  new Image.network("https://i2.hdslb.com/bfs/archive/0bf607f90c77f79ca2b1b461ff5096826ac6ce66.jpg@336w_190h.webp"),
                  new Image.network("https://i2.hdslb.com/bfs/archive/0bf607f90c77f79ca2b1b461ff5096826ac6ce66.jpg@336w_190h.webp"),
                  new Image.network("https://i2.hdslb.com/bfs/archive/0bf607f90c77f79ca2b1b461ff5096826ac6ce66.jpg@336w_190h.webp")
                ],
    

    这是效果图
    在这里插入图片描述

    LIstView初级用法第一节

  • 相关阅读:
    WinCE下SQLCE数据库开发(VS,VB.net,VC++)
    基于VC++的WinCE网口通信
    WinCE下的串口通信开发(VS2005,VB.Net,VC++)
    多线程CSerialPort类的多串口通信实现
    双T滤波电路用于PWM方式DAC的分析
    AD9516锁相环功能外接环路滤波器的设计与分析
    块结构中断有序化处理方法(一种单片机单线程方式下处理多中断的方法)
    STM32F10X固件库函数——串口清状态位函数分析
    STM32和STR71X移植uCos-II操作系统比较分析
    基于uIP和uC/OS-II嵌入式网络开发
  • 原文地址:https://www.cnblogs.com/yfc0818/p/11072664.html
Copyright © 2011-2022 走看看