flutter_data_stream_builder 0.0.2 copy "flutter_data_stream_builder: ^0.0.2" to clipboard
flutter_data_stream_builder: ^0.0.2 copied to clipboard

outdated

A pragmatic StreamBuilder with sensible defaults

DataStreamBuilder #

Pub

A pragmatic StreamBuilder with sensible defaults.

It uses three different builders:

  • builder: invoked only when stream data is ready (required as parameter)
  • loadingBuilder: invoked when waiting for data (not required, the library provides a default)
  • errorBuilder: invoked when an error is present in the stream (not required, the library provides a default)

Usage #

Using defaults for loading and error states:

DataStreamBuilder<List<Post>>(
  stream: Repository.of<Post>().findAll(),
  builder: (context, List<Post> posts) => ListView(
    children: posts.map((post) => ListTile(title: Text(post.body))).toList(),
  )
)

Custom loading and error widgets:

DataStreamBuilder<List<Post>>(
  stream: Repository.of<Post>().findAll(),
  loadingBuilder: (context) => Center(child: Text('Loading posts...')),
  errorBuilder: (context, error) => PostErrorView(error),
  builder: (context, List<Post> posts) => ListView(
    children: posts.map((post) => ListTile(title: Text(post.body))).toList(),
  )
)

See tests and the Example tab for a full example.

9
likes
0
pub points
0%
popularity

Publisher

verified publisherflutterdata.dev

A pragmatic StreamBuilder with sensible defaults

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on flutter_data_stream_builder