版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zx13525079024/article/details/86600405
ListView可以纵向显示也可以横向显示,使用scrollDirection属性控制,效果图如下
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter',
home: Scaffold(
appBar: AppBar(
title: Text("List View"),
),
body: Center(
child:Container(
height: 250,
child: new ListView(
scrollDirection:Axis.horizontal,
children: <Widget>[
Image.network("https://img14.360buyimg.com/n7/jfs/t12637/42/2327024214/114895/ec325f4f/5ab4b331Nbf564b11.jpg",width: 100),
Image.network("https://img10.360buyimg.com/n7/jfs/t18397/29/988914537/96851/e92ecd25/5ab4c6aaNb4df6198.jpg" ,width: 100),
Image.network("https://img13.360buyimg.com/n7/jfs/t18097/249/986540321/88281/625f677e/5ab4cb3bN0943eaf5.jpg",width: 100),
Image.network("https://img14.360buyimg.com/n7/jfs/t12637/42/2327024214/114895/ec325f4f/5ab4b331Nbf564b11.jpg",width: 100),
Image.network("https://img11.360buyimg.com/n7/jfs/t25342/205/1747435396/262760/8f54e2/5bbac0f7N012a9912.jpg",width: 100),
Image.network("https://img13.360buyimg.com/n7/jfs/t1/32177/13/911/356049/5c41b082E5bf24827/4e52c9a37f12082f.jpg",width: 100),
],
),
)
)
));
}
}