颤振网格布局:如何在颤振中使用网格布局进行这种布局

时间:2019-10-13 02:46:55

标签: flutter flutter-layout flutter-animation flutter-test flutter-sliver

i want to do like this grid layout, im very tired for this, im watching 3 playlist in some website and follow the some codes on some web site, but i did not get any ideas, please help me

我想做这样的网格布局,为此我非常疲倦,我正在某个网站上观看3个播放列表,并遵循某些网站上的某些代码,但是我没有任何想法,请帮助我< / strong>

2 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

以下是实现您想要的目标的快速示例:

List<String> exampleList = ["A", "B", "C", "D", "E", "F", "G", "H"];

@override
Widget build(BuildContext context) {
  return Scaffold(
    appBar: AppBar(title: Text('GridView')),
    body: GridView.builder(
      itemCount: exampleList.length,
      gridDelegate:
          SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2),
      itemBuilder: (context, index) {
        return Stack(
          fit: StackFit.expand,
          children: <Widget>[
            Image.network(
              "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTXRnL6cGSfn4coPWBk2JVca6hW95Oab_pzCcrWIl3Y7dHcyQ4I",
              fit: BoxFit.cover,
            ),
            Align(
              alignment: Alignment.bottomLeft,
              child: Container(
                padding: EdgeInsets.all(16.0),
                color: Colors.black38,
                child: Row(
                  children: <Widget>[
                    Flexible(
                      fit: FlexFit.tight,
                      child: Column(
                        mainAxisSize: MainAxisSize.min,
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: <Widget>[
                          Text('Title $index',
                              style: TextStyle(color: Colors.white)),
                          Text('Description ${exampleList[index]}',
                              style: TextStyle(color: Colors.white)),
                        ],
                      ),
                    ),
                    Icon(Icons.star_border, color: Colors.white),
                  ],
                ),
              ),
            )
          ],
        );
      },
    ),
  );
}