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.

Libraries

sliver_glue
sliver_glue.mobx

Dart

VM

dart:ffi
Foreign Function Interface for interoperability with the C programming language. [...]

Web

dart:html
HTML elements and other resources for web-based applications that need to interact with the browser and the DOM (Document Object Model). [...]
dart:js
Low-level support for interoperating with JavaScript. [...]
dart:js_util
Utility methods to efficiently manipulate typed JSInterop objects in cases where the name to call is not known at runtime. You should only use these methods when the same effect cannot be achieved with @JS annotations. These methods would be extension methods on JSObject if Dart supported extension methods.