sliver_glue 1.2.0

sliver_glue.dart | 1.2.0 #

Pub

Helpers for easily mixing content in a Flutter CustomScrollView, simple as ListView & GridView.

Inspiration #

sliver_glue exists mostly for mixing different kinds of content in a CustomScrollView. For a scrolling application, this is a possible common pattern in the same view.

  • Header widgets / AppBar
  • Grid of items
  • A list of items

To use all of these in a CustomScrollView, using SliverList and SliverGrid have more boilerplate than using ListView and GridView.

sliver_glue aims to help with that problem, and goes a little beyond this too (providing dismissable-ness and dividing lines, common use-cases).

Getting Started #

import 'package:flutter/material.dart';
import 'package:sliver_glue/sliver_glue.dart';

final List<String> text = ['A', 'B'];

class MyApp extends StatelessWidget {
  Widget _itemBuilder(BuildContext context, String str, _, __, ___) =>
    Text(data.text, key: Key(str));
 
  @override
  Widget build(BuildContext context) {
    return CustomScrollView(
      slivers: <Widget>[
        SliverGlueFixedList(
          widgets: <Widget>[
            Container(
              height: 200,
              child: Placeholder()
            )
          ],
        ),
        SliverGlueList(
          data: text,
          header: Text('Our List Header'),
          builder: _itemBuilder,
          divider: GlueDivider(enabled: true),
        ),
        SliverGlueGrid(
          data: text,
          builder: _itemBuilder,
          dismiss: GlueDismiss(enabled: true)
        )
      ],
    );
  }
}

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

MobX Integration #

sliver_glue also provides widgets for MobX's ObservableList in the form of SliverGlueObservableList. To use this widget, import package:sliver_glue/mobx.dart.

1.2.0 #

Breaking changes:

  • Abstract out dismissable and divided properties into their own classes, GlueDismiss and GlueDivider respectively.

New additions:

  • Added package:sliver_glue/mobx.dart with a SliverGlueObservableList widget. Due to Dart tree shaking this will not pull MobX into your project if you don't explicitly import the mobx.dart file.
  • Added footer and reversed options to SliverGlueObservableList.
  • Added support for trailingDivider to GlueDivider.

1.1.0 #

  • Use built-in hashCode instead of GlueKeyedData.

1.0.0 #

  • Initial release.

example/example.dart

import 'package:flutter/material.dart';
import 'package:sliver_glue/sliver_glue.dart';

final List<String> text = <String>[
  'A',
  'B'
];

class MyApp extends StatelessWidget {
  Widget _itemBuilder(BuildContext context, String data, _, __, ___) =>
    Text(data, key: Key(data.toString()));
 
  @override
  Widget build(BuildContext context) {
    return CustomScrollView(
      slivers: <Widget>[
        SliverGlueFixedList(
          widgets: <Widget>[
            Container(
              height: 200,
              child: Placeholder()
            )
          ],
        ),
        SliverGlueList(
          data: text,
          header: Text('Our List Header'),
          builder: _itemBuilder,
          divider: GlueDivider(enabled: true),
        ),
        SliverGlueGrid(
          data: text,
          builder: _itemBuilder,
          dismiss: GlueDismiss(enabled: true),
        )
      ],
    );
  }
}

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

Use this package as a library

1. Depend on it

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


dependencies:
  sliver_glue: ^1.2.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:sliver_glue/sliver_glue.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
74
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
85
Learn more about scoring.

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

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.3

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Format lib/mobx.dart.

Run flutter format to format lib/mobx.dart.

Format lib/sliver_glue.dart.

Run flutter format to format lib/sliver_glue.dart.

Format lib/src/glue_dismiss.dart.

Run flutter format to format lib/src/glue_dismiss.dart.

Fix additional 5 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/src/glue_divider.dart (Run flutter format to format lib/src/glue_divider.dart.)
  • lib/src/mobx/sliver_glue_observable_list.dart (Run flutter format to format lib/src/mobx/sliver_glue_observable_list.dart.)
  • lib/src/sliver_glue_fixed_list.dart (Run flutter format to format lib/src/sliver_glue_fixed_list.dart.)
  • lib/src/sliver_glue_grid.dart (Run flutter format to format lib/src/sliver_glue_grid.dart.)
  • lib/src/sliver_glue_list.dart (Run flutter format to format lib/src/sliver_glue_list.dart.)

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (mobx).

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
mobx ^0.0.36 0.0.37 0.3.4
Transitive dependencies
collection 1.14.11
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test

Admin