Skip to content
pubscout

sticky_headers

0.3.0+2, released 5 years ago by fluttercommunity.dev

Lets you place headers on scrollable content that stick to the top.

WASM-ready
$ flutter pub add sticky_headers
Source repository

What it does

Provides StickyHeader and StickyHeaderBuilder widgets that can be placed inside scrollable content like ListView or GridView. Keeps headers visible at the top of the container while the user scrolls through the associated content.

AI-written summary of version 0.3.0+2, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need section headers that stick to the top of scrollable lists or grids.
  • You are building categorized scrollable views in Flutter.

Skip it when

  • You need complex sliver-based sticky headers managed directly by a CustomScrollView rather than wrapper widgets.
  • You need features not provided by basic sticky headers.

Strengths

  • Works inside standard scrollables like ListView and GridView.
  • Supports custom layouts via StickyHeaderBuilder.

Weaknesses

  • Limited to the options provided by the wrapper-based widget approach.

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
0
class Example extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return ListView.builder(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 #$index',
            style: const TextStyle(color: Colors.white),
          ),
        ),
        content: Container(
          child: Image.network(
            imageForIndex(index), 
            fit: BoxFit.cover,
            width: double.infinity, 
            height: 200.0,
          ),
        );
      );
    });
  }
}

Alternatives

Packages that do the same job and could replace sticky_headers.