flutter_sticky_header 0.4.0

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 62

flutter_sticky_header #

A Flutter implementation of sticky headers with a sliver as a child.

Pub Donate

Screenshot

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).

Getting started #

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

dependencies:
  ...
  flutter_sticky_header: "^0.3.4"

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.

new SliverStickyHeader(
  header: new Container(
    height: 60.0,
    color: Colors.lightBlue,
    padding: EdgeInsets.symmetric(horizontal: 16.0),
    alignment: Alignment.centerLeft,
    child: new Text(
      'Header #0',
      style: const TextStyle(color: Colors.white),
    ),
  ),
  sliver: new SliverList(
    delegate: new SliverChildBuilderDelegate(
      (context, i) => new ListTile(
            leading: new CircleAvatar(
              child: new Text('0'),
            ),
            title: new Text('List tile #$i'),
          ),
      childCount: 4,
    ),
  ),
);

SliverStickyHeaderBuilder #

If you want to change the header layout during its scroll, you can use the SliverStickyHeaderBuilder.

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

new SliverStickyHeaderBuilder(
  builder: (context, state) => new 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: new Text(
          'Header #1',
          style: const TextStyle(color: Colors.white),
        ),
      ),
  sliver: new SliverList(
    delegate: new SliverChildBuilderDelegate(
      (context, i) => new ListTile(
            leading: new CircleAvatar(
              child: new Text('0'),
            ),
            title: new Text('List tile #$i'),
          ),
      childCount: 4,
    ),
  ),
);

You can find more examples in the Example project.

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.

Thanks #

👏 Thanks to slightfoot with it's RenderBox version (https://github.com/slightfoot/flutter_sticky_headers) which unintentionally challenged me to work in this RenderSliver version.

0.4.0 #

  • Updated SDK constraint to support new error message formats.
  • Updated error message formats

0.3.4 #

Removed #

  • Print call for headerPosition

0.3.3 #

Added #

  • Overlap support

0.3.2 #

Added #

  • Dart 2 support

0.3.1 #

Fixed #

0.3.0 #

Added #

  • SliverStickyHeaderState class. This state has scrollPercentage and isPinned properties and it's passed to the SliverStickyHeaderBuilder when it changes.

Changed #

  • The second parameter for SliverStickyHeaderWidgetBuilder takes now a SliverStickyHeaderState instead of a double.

0.2.0 #

Removed #

  • sliverStickyHeaderScrollNotifier argument in SliverStickyHeader constructor.

Changed #

  • Rewrite how to notify the scroll percentage, so that the it does not lag by one frame.

0.1.0 #

  • Initial Open Source release.

example/README.md

example #

A new Flutter project.

Getting Started #

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

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_sticky_header: ^0.4.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or 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_sticky_header/flutter_sticky_header.dart';
  
Version Uploaded Documentation Archive
0.4.0 May 23, 2019 Go to the documentation of flutter_sticky_header 0.4.0 Download flutter_sticky_header 0.4.0 archive
0.3.4 Aug 25, 2018 Go to the documentation of flutter_sticky_header 0.3.4 Download flutter_sticky_header 0.3.4 archive
0.3.3 Aug 22, 2018 Go to the documentation of flutter_sticky_header 0.3.3 Download flutter_sticky_header 0.3.3 archive
0.3.2 Jul 21, 2018 Go to the documentation of flutter_sticky_header 0.3.2 Download flutter_sticky_header 0.3.2 archive
0.3.1 Jul 18, 2018 Go to the documentation of flutter_sticky_header 0.3.1 Download flutter_sticky_header 0.3.1 archive
0.3.0 Jun 30, 2018 Go to the documentation of flutter_sticky_header 0.3.0 Download flutter_sticky_header 0.3.0 archive
0.2.0 Jun 24, 2018 Go to the documentation of flutter_sticky_header 0.2.0 Download flutter_sticky_header 0.2.0 archive
0.1.0 Jun 16, 2018 Go to the documentation of flutter_sticky_header 0.1.0 Download flutter_sticky_header 0.1.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
96
Health:
Code health derived from static analysis. [more]
0
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
62
Learn more about scoring.

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

  • Dart: 2.3.1
  • pana: 0.12.16
  • Flutter: 1.5.4-hotfix.2

Platforms

Detected platforms:

Error(s) prevent platform classification:

Fix dependencies in pubspec.yaml.

Analysis issues and suggestions

Fix dependencies in pubspec.yaml.

Running flutter packages pub upgrade failed with the following output:

ERR: The current Flutter SDK version is 1.5.4-hotfix.2.
 
 Because flutter_sticky_header requires Flutter SDK version >=1.5.9-pre.94 <2.0.0, version solving failed.

Maintenance issues and suggestions

Fix platform conflicts. (-20 points)

Error(s) prevent platform classification:

Fix dependencies in pubspec.yaml.

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.0 <3.0.0