stream_mixin 1.0.0 copy "stream_mixin: ^1.0.0" to clipboard
stream_mixin: ^1.0.0 copied to clipboard

outdated

A simple mixin for adding a stream behaviour to any class object

stream_mixin #

A simple mixin for adding a stream behaviour to any class object

Getting Started #

To make a class subscribable create the class with [StreamMixin]

Create a service #

class AppTagService with StreamMixin<String> {
  AppTagService._();
  static final AppTagService instance = AppTagService._();
}

Subscribe to change of the tag service #

class CurrentTag extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return StreamBuilder<String>(
      builder: (context, snap) => Text(snap.data),
      stream: AppTagService.instance.onChange, //⭐
    );
  }
}

Change current tag #

Note, tag can be changed from any place in the app because it does not need context or state.

someFunction() {
  AppTagService.instance.change('COVID-19');
}
6
likes
0
pub points
78%
popularity

Publisher

verified publisherdart.nonstopio.com

A simple mixin for adding a stream behaviour to any class object

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on stream_mixin