zoukankan      html  css  js  c++  java
  • ListView

    列表使用

    body: new ListView(
              children: <Widget>[
                /*new Image.network(
                    'https://cdn2.jianshu.io/assets/web/banner-s-club-aa8bdf19f8cf729a759da42e4a96f366.png'),
                new Image.network(
                    'https://cdn2.jianshu.io/assets/web/banner-s-7-1a0222c91694a1f38e610be4bf9669be.png'),
                 */ //图片列表使用
                new ListTile(
                  leading: new Icon(
                    Icons.perm_camera_mic,
                  ),
                  title: new Text('perm_camera_mic'),
                ),
                new ListTile(
                  leading: new Icon(
                    Icons.perm_phone_msg,
                  ),
                  title: new Text('perm_phone_msg'),
                ),
              ],
            ),

    横向列表:ListView组件里加一个scrollDirection属性

    body: new Center(
                child: new Container(
                    height: 200.0,
                    child: new ListView(
                      scrollDirection: Axis.horizontal, //Axis.vertical:纵向列表
                      children: <Widget>[
                        new Container(
                           230.0,
                          color: Colors.lightBlue,
                        ),
                        new Container(
                           230.0,
                          color: Colors.lightGreen,
                        ),
                      ],
                    ))),

    Dart语言List的声明方式:

    • var myList = List(): 非固定长度的声明。
    • var myList = List(2): 固定长度的声明。
    • var myList= List<String>():固定类型的声明方式。
    • var myList = [1,2,3]: 对List直接赋值
    import 'package:flutter/material.dart';
    
    void main() =>
        runApp(MyApp(items: List<String>.generate(1000, (i) => 'item $i')));
    
    class MyApp extends StatelessWidget {
      final List<String> items;
      MyApp({Key key, @required this.items}) : super(key: key);
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          title: 'ListView Dome',
          home: new Scaffold(
            appBar: new AppBar(title: new Text('ListView Widget')),
            body: new ListView.builder(
                itemCount: items.length,
                itemBuilder: (context, index) {
                  return new ListTile(
                    title: new Text('${items[index]}'),
                  );
                }),
          ),
        );
      }
    }
  • 相关阅读:
    Linux运维常见故障排查和处理的技巧汇总
    React 页面开发服务规范抽象
    解决 NVM 安装 Node 版本出现 TLS 问题
    解决部署 React 框架 Next.js 到 IIS 上刷新页面出现 404 问题
    正则表达式
    rsa加解密代码实现
    zookeeper介绍(5)快速入门教程
    yii2-adminlte-asset中MenuHelper 菜单伸缩问题
    yii2-admin autocomplete 输出弹出框位置不对
    php curl模拟常用的请求
  • 原文地址:https://www.cnblogs.com/timba1322/p/12486562.html
Copyright © 2011-2022 走看看