4

I'm trying display a slivergridview view and it just doesn't look good if it's always on full width especially on large screens

enter image description here

But CustomScrollView only accepts sliver widgets, which makes container & sizedbox unusable. What is your workaround on this one?

Mark Dionnie
  • 305
  • 4
  • 11

1 Answers1

4
  1. First, wrap your Scaffold body with LayoutBuilder
  2. Wrap SliverGrid with SliverPadding and set the vertical and horizontal width
    SliverPadding(
      padding: EdgeInsets.symmetric(
      vertical: 15,
      horizontal: max((constraints.maxWidth - 1200) / 2, 0) > 15 ? max((constraints.maxWidth - 1200) / 2, 0) : 15),
      sliver: SliverGrid( ...

Here's the result enter image description here

rehman_00001
  • 1,299
  • 1
  • 15
  • 28
Mark Dionnie
  • 305
  • 4
  • 11