Flutter listview

ListView 列表组件

  • 使用了ListView,然后在他的内部children中,使用了widget数组,因为是一个列表,所以它接受一个数组,然后有使用了listTite组件(列表瓦片),在组件中放置了图标和文字。

  • 放入图标和文字

import 'package:flutter/material.dart';
void main () => runApp(MyApp());

class MyApp extends StatelessWidget{
  @override
  Widget build(BuildContext context){
    return MaterialApp(
      title: 'Hello world',
      home: Scaffold(
        appBar: AppBar(
          title: Text('Flutter')
        ),
        body: new ListView(
          children:<Widget>[
            new ListTile(
              leading:new Icon(Icons.access_time),
              title:new Text('access_time')
            ),
            new ListTile(
              leading:new Icon(Icons.account_balance),
              title:new Text('account_balance')
            ),
          ]
        ),
      ),
    );
  }
}

  • 放入多个图片
import 'package:flutter/material.dart';
void main () => runApp(MyApp());

class MyApp extends StatelessWidget{
  @override
  Widget build(BuildContext context){
    return MaterialApp(
      title: 'Hello world',
      home: Scaffold(
        appBar: AppBar(
          title: Text('Flutter')
        ),
        body: new ListView(
          children:<Widget>[
            new Image.network(
             'http://pic.58pic.com/58pic/15/11/51/20E58PICNs4_1024.jpg'
            ),
            new Image.network(
             'http://pic.58pic.com/58pic/15/11/51/20E58PICNs4_1024.jpg'
            ),
          ]
        ),
      ),
    );
  }
}
发布了24 篇原创文章 · 获赞 4 · 访问量 4468

猜你喜欢

转载自blog.csdn.net/Amo__/article/details/90229938