带有粘性标题的 Gridview.builder

时间:2021-01-28 20:04:51

标签: flutter

我很沮丧。

我需要一个 Gridview.builder(或每行 3 列的 Listview) 并且在网格顶部我需要 1 个标题。

然而我的代码要么把 3 列列表搞砸了,要么把标题搞砸了,然后会变成三倍。

我是一个完全的编码新手。但我正在拼命解决这个问题。

请提前为错误的代码道歉。

GridView.builder(
      gridDelegate:
        SliverGridDelegateWithFixedCrossAxisCount(
            crossAxisCount: 3,),
        itemCount: 210,
        itemBuilder: (context, index) {
      return StickyHeader(
        header: Container(
          height: 50.0,
          color: Colors.blueGrey[700],
          padding: EdgeInsets.symmetric(horizontal: 16.0),
          alignment: Alignment.centerLeft,
          child: Text('Header',
            style: const TextStyle(color: Colors.white),
          ),
        ),
        content: Column(
          children:
          List<int>.generate(21, (index) => index)
              .map((item) => Container(
            decoration:
            BoxDecoration( //                    <-- BoxDecoration
                border: Border(bottom: BorderSide())
            ),
            height: 50,
            width: 5000000,
            child: Text ('Test'),

          ))
              .toList(),
          ),
        );

        }),

1 个答案:

答案 0 :(得分:0)

我会使用 export LD_LIBRARY_PATH=../../../PDFNetC/Lib ,其中第一个子项是标题,第二个子项是 Column 小部件内的 GridView

类似于this

或者您可以在 Expanded 中使用条子。简短教程here