flutter_staggered_grid_view 0.3.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 95

flutter_staggered_grid_view #

A Flutter staggered grid view which supports multiple columns with rows of varying sizes.

Pub Donate


Features #

  • Configurable cross-axis count or max cross-axis extent like the GridView
  • Tiles can have a fixed main-axis extent, or a multiple of the cell's length.
  • Configurable main-axis and cross-axis margins between tiles.
  • SliverStaggeredGrid for using in a CustomScrollView.
  • Staggered and Spannable grid layouts.

Screenshot Screenshot

  • Tiles can fit the content in the main axis.


Getting started #

In the pubspec.yaml of your flutter project, add the following dependency:

  flutter_staggered_grid_view: "^0.2.7"

In your library add the following import:

import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';

For help getting started with Flutter, view the online documentation.

Example #


new StaggeredGridView.countBuilder(
  crossAxisCount: 4,
  itemCount: 8,
  itemBuilder: (BuildContext context, int index) => new Container(
      color: Colors.green,
      child: new Center(
        child: new CircleAvatar(
          backgroundColor: Colors.white,
          child: new Text('$index'),
  staggeredTileBuilder: (int index) =>
      new StaggeredTile.count(2, index.isEven ? 2 : 1),
  mainAxisSpacing: 4.0,
  crossAxisSpacing: 4.0,

You can find more examples in the Example project.

Constructors #

The StaggeredGridView follow the same constructors convention than the GridView.
There are two more constructors: countBuilder and extentBuilder. These constructors allow you to define a builder for the layout and a builder for the children.

Tiles #

A StaggeredGridView needs to know how to display each tile, and what widget is associated with a tile.

A tile needs to have a fixed number of cell to occupy in the cross axis. For the extent in the main axis you have 3 options:

  • You want a fixed number of cells => use StaggeredTile.count.
  • You want a fixed extent => use StaggeredTile.extent.
  • You want a variable extent, defined by the content of the tile itself => use StaggeredTile.fit.

Changelog #

Please see the Changelog page to know what's recently changed.

Contributions #

Feel free to contribute to this project.

If you find a bug or want a feature, but don't know how to fix/implement it, please fill an issue.
If you fixed a bug or implemented a new feature, please send a pull request.

0.3.0 #

Fixed #

0.2.7 #

Fixed #

  • Better fix for the bug where items are built only once.

0.2.6 #

Fixed #

  • Fix a bug where items are built only once.

0.2.5 #

Changed #

  • Use the new SliverWithKeepAliveWidget.

0.2.4 #

Fixed #

  • Dart 2.1 mixin support.

0.2.3 #

Fixed #

0.2.2 #

  • Add Dart 2 support.

0.2.1 #

  • Fix #10 StatefulWidget.createState must return a subtype of State<AutomaticKeepAliveVariableSizeBox>.

0.2.0 #

  • Add a way to let the tile's content to define the tile's extent in the main axis.
  • Add fit constructor to StaggeredTile.

0.1.4 #

  • Add countBuilder and extendBuilder constructors to SliverStaggeredGrid

0.1.3 #

  • Remove Flutter SDK constraint

0.1.2 #

  • Remove update Flutter SDK constraint

0.1.1 #

  • Fix images in readme
  • Add dynamic resizing demo

0.1.0 #

  • Initial Open Source release


import 'package:flutter/material.dart';

import 'routes.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'StaggeredGridView Demo',
      theme: new ThemeData(
        primarySwatch: Colors.blue,
      routes: routes,

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  flutter_staggered_grid_view: ^0.3.0

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on May 24, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.1
  • pana: 0.13.8-dev
  • Flutter: 1.17.0

Health suggestions

Fix lib/src/widgets/sliver.dart. (-0.50 points)

Analysis of lib/src/widgets/sliver.dart reported 1 hint:

line 185 col 8: This method overrides a method annotated as '@mustCallSuper' in 'Element', but doesn't invoke the overridden method.

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
test ^1.5.1