How to center SliverGrid?

Viewed 284

I want to center a fixed width GridView in CustomScrollView horizontally.

But I couldn't find a way to align as sliver. How can I do this? Maybe I can use SliverToBoxAdapter to use Center but is there no performance penalty?

The following is pseudo code for this.

CustomScrollView(
  slivers: [
    SliverToBoxAdapter(
      Center(child: Text('I can do it'))
    ),
    SliverAlign?(
      alignment: Alignment.topCenter,
      child: SliverSizedBox?(
        width: 600,
        sliver: SliverGrid.count(
          crossAxisCount: 2,
          mainAxisSpacing: 24,
          childAspectRatio: 0.9,
          crossAxisSpacing: 8,
          children: [
            Text('SliverAlign and SliverSizedBox does not exist')
          ],
    ))),
]);
0 Answers
Related