Slide 11
Slide 11 text
Future and Stream Provider
• FutureProvider is typically used –
• performing and caching asynchronous
operations (such as network requests)
• nicely handling error/loading states of
asynchronous operations
• removes redundancies of FutureBuilder
• StreamProvider is like FutureProvider but
for Stream instead of Future.
• StreamProvider is usually used –
• it allows other providers to listen to the
stream using ref.watch.
• it caches the latest value emitted by the
stream, ensuring that if a listener is
added after an event is emitted, the listener
will still have immediate access to the most
up-to-date event.
Creating the configuration would be done with your typical
async/await syntax, but inside the provider. Using Flutter's
asset system, this would be: