Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

flutter_sticky_header

a flutter implementation of sticky headers with a sliver as a child.

sticky_header_all

features

  • accepts one sliver as content.
  • header can overlap its sliver (useful for sticky side header for example).
  • notifies when the header scrolls outside the viewport.
  • can scroll in any direction.
  • supports overlapping (appbars for example).
  • supports not sticky headers (with sticky: false parameter).
  • supports a controller which notifies the scroll offset of the current sticky header.

getting started

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

dependencies:
  ...
  flutter_sticky_header:

in your library add the following import:

import 'package:flutter_sticky_header/flutter_sticky_header.dart';

for help getting started with flutter, view the online documentation.

sliverstickyheader

you can place one or multiple sliverstickyheaders inside a customscrollview.

sliverstickyheader(
  header: container(
    height: 60.0,
    color: colors.lightblue,
    padding: edgeinsets.symmetric(horizontal: 16.0),
    alignment: alignment.centerleft,
    child: text(
      'header #0',
      style: const textstyle(color: colors.white),
    ),
  ),
  sliver: sliverlist(
    delegate: sliverchildbuilderdelegate(
      (context, i) => listtile(
            leading: circleavatar(
              child: text('0'),
            ),
            title: text('list tile #$i'),
          ),
      childcount: 4,
    ),
  ),
);

sliverstickyheader.builder

if you want to change the header layout during its scroll, you can use the sliverstickyheader.builder constructor.

the example belows changes the opacity of the header as it scrolls off the viewport.

sliverstickyheader.builder(
  builder: (context, state) => container(
        height: 60.0,
        color: (state.ispinned ? colors.pink : colors.lightblue)
            .withopacity(1.0 - state.scrollpercentage),
        padding: edgeinsets.symmetric(horizontal: 16.0),
        alignment: alignment.centerleft,
        child: text(
          'header #1',
          style: const textstyle(color: colors.white),
        ),
      ),
  sliver: sliverlist(
    delegate: sliverchildbuilderdelegate(
      (context, i) => listtile(
            leading: circleavatar(
              child: text('0'),
            ),
            title: text('list tile #$i'),
          ),
      childcount: 4,
    ),
  ),
);

you can find more examples in the example project.


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

Comments are closed.