纵向列表与横向列表

ListView 列表 - 图1

  1. home: Scaffold(
  2. appBar: AppBar(
  3. title: Text('ListView'),
  4. ),
  5. body: new ListView(
  6. children: <Widget>[
  7. new ListTile(
  8. leading: new Icon(Icons.access_alarms),
  9. title: Text('hhhh'),
  10. ),new ListTile(
  11. leading: new Icon(Icons.access_time),
  12. title: Text('xxxx'),
  13. ),
  14. new Image.network(
  15. 'https://image.uisdc.com/wp-content/uploads/2018/12/uisdc-banner-20181214-6.jpg',
  16. ),new Image.network(
  17. 'https://image.uisdc.com/wp-content/uploads/2018/12/uisdc-banner-20181208-4.jpg',
  18. ),new Image.network(
  19. 'https://image.uisdc.com/wp-content/uploads/2018/12/uisdc-banner-20181207-4.jpg',
  20. ),new Image.network(
  21. 'https://image.uisdc.com/wp-content/uploads/2018/12/uisdc-banner-20181211-4.jpg'
  22. )
  23. ],
  24. )
  25. ),

横向

加一条语句
ListView 列表 - 图2

ListView 列表 - 图3

动态列表

  1. import 'package:flutter/material.dart';
  2. void main() => runApp(MyApp(
  3. items: new List<String>.generate(
  4. 5, (i)=>"itens $i")//length 长度,匿名函数
  5. ));
  6. class MyApp extends StatelessWidget {
  7. // This widget is the root of your application.
  8. final List<String> items;
  9. MyApp({Key key,@required this.items}):super(key:key);
  10. @override
  11. Widget build(BuildContext context) {
  12. return MaterialApp(
  13. title: 'Flutter Demo',
  14. theme: ThemeData(
  15. primarySwatch: Colors.blue,
  16. ),
  17. home: Scaffold(
  18. appBar: new AppBar(title: new Text ('mystudys')),
  19. body: new ListView.builder(
  20. itemCount: items.length,//使用
  21. itemBuilder: (context,index){
  22. return new ListTile(
  23. title: new Text('哈哈哈 ${items[index]}'),
  24. );
  25. },
  26. ),
  27. ),
  28. );
  29. }
  30. }

一个人写了比较多的flutter https://blog.csdn.net/z979451341/article/details/80899980