【发布时间】:2021-01-27 10:56:00
【问题描述】:
我尝试使用 StaggeredGridView,但它不会在我的页面上加载任何内容,甚至不仅仅是文本。我还没有放图片网址,因为我想测试一下。
到目前为止,这是我的以下代码:
body: ListView(
children: [
Container(
width: deviceSize.width,
height: 650,
child: Stack(
alignment: AlignmentDirectional.center,
children: [
Image.asset(
'assets/Big Sur.jpg',
width: deviceSize.width,
fit: BoxFit.cover,
),
Stack(
children: [
Text(
"""\n\n\nA decentralized photography platform\nfor the devoted communities.""",
style: TextStyle(
color: Colors.white,
fontSize: 30,
),
),
Text(
'PhoBlock',
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.white,
fontSize: 80,
),
)
],
),
],
),
),
SizedBox(
height: 50,
),
StaggeredGridView.countBuilder(
crossAxisCount: 4,
itemBuilder: (BuildContext context, int index) {
return Container(
color: Colors.green,
child: new Center(
child: new CircleAvatar(
backgroundColor: Colors.white,
child: new Text('$index'),
),
),
);
},
staggeredTileBuilder: (int index) {
return StaggeredTile.count(2, index.isEven ? 2 : 1);
},
mainAxisSpacing: 4.0,
crossAxisSpacing: 4.0,
),
这是来自 Scaffold 小部件的主体。请帮助我,因为我正在尝试弄清楚如何使用这个新的 StaggeredGridView 小部件...
【问题讨论】:
-
使用列并删除列表视图
-
你也可以使用 Expanded 并在 expand 的 child 中添加 gridview
标签: image flutter flutter-web