![](/img/trans.png)
[英]How can I make a card type layout for a Pinterest-type masonry layout?
[英]How to Make Masonry Layout in Flutter?
您也可以使用Flutter 布局網格
運行$ flutter pub add flutter_layout_grid
進行安裝
使用此代碼制作
class PietPainting extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
color: background,
child: LayoutGrid(
columnGap: 12,
rowGap: 12,
areas: '''
r R B B B
r R Y Y Y
y R Y Y Y
y R g b yy
''',
// A number of extension methods are provided for concise track sizing
columnSizes: [1.0.fr, 3.5.fr, 1.3.fr, 1.3.fr, 1.3.fr],
rowSizes: [
1.0.fr,
0.3.fr,
1.5.fr,
1.2.fr,
],
children: [
// Column 1
gridArea('r').containing(Container(color: cellRed)),
gridArea('y').containing(Container(color: cellMustard)),
// Column 2
gridArea('R').containing(Container(color: cellRed)),
// Column 3
gridArea('B').containing(Container(color: cellBlue)),
gridArea('Y').containing(Container(color: cellMustard)),
gridArea('g').containing(Container(color: cellGrey)),
// Column 4
gridArea('b').containing(Container(color: cellBlue)),
// Column 5
gridArea('yy').containing(Container(color: cellMustard)),
],
),
);
}
}
class PietNamedAreasApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return WidgetsApp(
title: 'Layout Grid Desktop Example',
debugShowCheckedModeBanner: false,
color: Colors.white,
builder: (context, child) => PietPainting(),
);
}
}
您可以使用flutter_staggerd_gridview package
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.