snaplist 0.1.8

  • Readme
  • Changelog
  • Example
  • Installing
  • 94

awesome flutter pub package

snaplist #

A small cozy library that allows you to make snappable list views.

Issues and Pull Requests are really appreciated!

Snaplist supports different and even dynamically sized children to be listed and correctly snapped.

Showcase #

Showscase gif

Include to your project #

In your pubspec.yaml root add:

  snaplist: ^0.1.8

Include #

The library does provide StatefulWidget which is called SnapList.

Include the widget like this: import 'package:snaplist/snaplist.dart';

Usage #

Use it as you'd use any widget:

Widget build(BuildContext context) {
  return SnapList(
    sizeProvider => (index, data) => Size(100.0, 100.0),
    separatorProvider => (index, data) => Size(10.0, 10.0),
    builder: (context, index, data) => SizedBox(),
    count: 1,

Snaplist uses gesture detection for swiping the list, so, please, be sure that the gestures you apply to the widgets inside are not overlapping for best user experience.

Properties #

There are 4 required fields:

  • sizeProvider is a provider of each widget size. The library will wrap each built widget to a sized box of specified size. This is required so snapping calculations will work correctly.
  • separatorProvider is similar to sizeProvider, but this size will be used to build the list separators.
  • builder works like a regular Flutter builder all of us are familiar with. It will pass you the context, current item index and some additional data.
  • count - Children count as in a ListView.

The data which is provided to each provider and the builder is a combination of three fields:

  • center - is the position which is now displayed and referenced as the center widget.
  • next - is the position which the user is scrolling to. It is -1 if idle.
  • progress - is the scroll and snip progress. The values are from 0 to 100.

Snaplist defaults to horizontal scrolling. You can set axis to Axis.vertical for vertical scrolling.

Changelog #

[0.1.8] - 16.03.2019

  • Introducing SnaplistController to allow initial item position and setting position programatically.

[0.1.7] - 01.02.2019

  • Hot reload did nothing to snaplist. Now it is fixed. A big thanks to @raacker.

[0.1.6] - 31.10.2018

  • Hot reload did nothing to snaplist. Now it is fixed. A big thanks to @raacker.

[0.1.5] - 28.10.2018

  • Implements vertical axis scroll and snip. A big thanks to @raacker.

[0.1.4] - 27.10.2018

  • Adds a simple example to the package

[0.1.3] - 26.10.2018

  • Readme and organizational updates.

[0.1.2] - 25.10.2018

  • Implements snapping back to original item if not enough velocity or progress

[0.1.1] - 24.10.2018

  • Explicitly provides current item position, does not hide it in builder data
  • Removes unnessesary setState calls from snip animation

[0.1.0] - 21.10.2018

  • It's alive!


example #

Sample app for the Snaplist library.


This application shows two uses case of using snaplist - vertical and horizontal snapping.

The only actual difference between those two is the axis value. But I still believe it is important considering both options, especially if you are providing some additional gestures to the displayed item.

Please, be sure that your gesture does not conflict with the gesture which is used for the list scroll and snaps.

Use this package as a library

1. Depend on it

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

  snaplist: ^0.1.8

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:snaplist/snaplist.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 Jan 24, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4
  • Flutter: 1.12.13+hotfix.5

Health issues and suggestions

Document public APIs. (-0.71 points)

101 out of 102 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Format lib/snaplist.dart.

Run flutter format to format lib/snaplist.dart.

Format lib/snaplist_bloc.dart.

Run flutter format to format lib/snaplist_bloc.dart.

Format lib/snaplist_controller.dart.

Run flutter format to format lib/snaplist_controller.dart.

Format lib/snaplist_events.dart.

Run flutter format to format lib/snaplist_events.dart.

Format lib/snaplist_view.dart.

Run flutter format to format lib/snaplist_view.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies