import ‘package:flutter/material.dart‘; import ‘res/listData.dart‘; void main() { runApp(MaterialApp( title: "demo", home: MyApp(), )); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text("FlutterDemo"),), body: ListView( children: listData.map((value) { return Card( margin: EdgeInsets.all(10), child: Column( children: <Widget>[ AspectRatio( aspectRatio: 20/9, child: Image.network(value["imageUrl"],fit: BoxFit.cover,), ), ListTile( leading: CircleAvatar( backgroundImage: NetworkImage(value["imageUrl"]), ), title: Text(value["title"]), subtitle: Text(value["description"],maxLines: 1,overflow: TextOverflow.ellipsis), ) ], ), ); }).toList() ) ); } }
原文地址:https://www.cnblogs.com/chichung/p/11994396.html
时间: 2024-11-04 16:15:06