【发布时间】:2020-03-13 11:29:21
【问题描述】:
我想在 GridView 中显示图像列表。而我无法做到这一点。我想知道资产中图像列表的数据类型以及在这种情况下构造函数将如何提供帮助。刚开始学flutter,不知道怎么用。
class Home extends StatefulWidget {
final String title;
Home({this.title}) : super();
@override
_HomeState createState() => _HomeState();
}
@override
Widget build(BuildContext context) {
var gridView = new GridView.builder(
itemCount: 20,
gridDelegate:
new SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3),
itemBuilder: (BuildContext context, int index) {
return new GestureDetector(
child: new Card(
elevation: 10,
child: new Container(
// child: *Image list as child*, but don't know about the list datatype hence not created it!
alignment: Alignment.center,
),
),
onTap: () {},
);
});
return new Scaffold(
appBar: new AppBar(
backgroundColor: Colors.red,
title: new Text("Flutter TabBar"),
),
body: Container(
padding: EdgeInsets.all(10),
child: gridView,
),
);
}
}
【问题讨论】:
-
这能回答你的问题吗? How to add image in Flutter