stream_provider 0.0.1 copy "stream_provider: ^0.0.1" to clipboard
stream_provider: ^0.0.1 copied to clipboard

discontinued

A package makes it easy for you to use stream with Provider.

Stream Provider #

Coverage GitHub issues GitHub stars GitHub license


A package makes it easy for you to use stream with Provider.

Pros

  • Doesn't need call notifyListeners everytime, everywhere.
  • Able to use power of stream and RxDart, when you have to deal with complex tasks

Cons

  • Need to close() every Stream that you declare into Provider inside dispose()

Usage #

Exposing a value #

Exposing a new object instance

Create a new object inside create.

StreamProvider(
  create: (_) => new MyModel(),
  child: ...

Reusing an existing object instance:

If you already have an object instance and want to expose it, you should use the .value constructor of a provider.

Failing to do so may call the dispose method of your object when it is still in use.

Use StreamProvider.valueto provide an existingProvider.

MyProvider variable;

StreamProvider.value(
  value: variable,
  child: ...
)

Reading a value #

The easiest way to read a value is by using the static method

StreamProvider.of

or

context.provider<T>()

This method will look up in the widget tree starting from the widget associated with the BuildContext passed and it will return the nearest variable of type T found (or throw if nothing is found)

0
likes
30
points
1
downloads

Publisher

unverified uploader

Weekly Downloads

A package makes it easy for you to use stream with Provider.

License

MIT (license)

Dependencies

flutter, provider, rxdart

More

Packages that depend on stream_provider