Answers for "staggered grid view flutter"

-2

grid view in flutter

CustomScrollView(
  primary: false,
  slivers: <Widget>[
    SliverPadding(
      padding: const EdgeInsets.all(20),
      sliver: SliverGrid.count(
        crossAxisSpacing: 10,
        mainAxisSpacing: 10,
        crossAxisCount: 2,
        children: <Widget>[
          Container(
            padding: const EdgeInsets.all(8),
            child: const Text("He'd have you all unravel at the"),
            color: Colors.green[100],
          ),
          Container(
            padding: const EdgeInsets.all(8),
            child: const Text('Heed not the rabble'),
            color: Colors.green[200],
          ),
          Container(
            padding: const EdgeInsets.all(8),
            child: const Text('Sound of screams but the'),
            color: Colors.green[300],
          ),
          Container(
            padding: const EdgeInsets.all(8),
            child: const Text('Who scream'),
            color: Colors.green[400],
          ),
          Container(
            padding: const EdgeInsets.all(8),
            child: const Text('Revolution is coming...'),
            color: Colors.green[500],
          ),
          Container(
            padding: const EdgeInsets.all(8),
            child: const Text('Revolution, they...'),
            color: Colors.green[600],
          ),
        ],
      ),
    ),
  ],
)
Posted by: Guest on December-11-2020
0

flutter staggered grid view

StaggeredGridView.countBuilder(
  primary: false,
  shrinkWrap: true,
  key: ObjectKey(ResponsiveWidget.isSmallScreen(context) ? 2 :4),
  // **add this line**
  crossAxisCount: ResponsiveWidget.isSmallScreen(context) ? 4 : 8,
  itemCount: ResponsiveWidget.isSmallScreen(context) ? 4 : _productsList.length,
  itemBuilder: (BuildContext context, int index) {
    BannersResult product = _productsList.elementAt(index);
    return Home_CustBanner_twobytwo_Item(
      home_banner_list_item: product,
      heroTag: 'categorized_products_grid',
    );
  },

  staggeredTileBuilder: (int index) => new StaggeredTile.fit(2),
  mainAxisSpacing: 15.0,
  crossAxisSpacing: 15.0,
),
Posted by: Guest on October-14-2021

Browse Popular Code Answers by Language