Now this feature is stable, we should use it. I might have missed some usecases, but these can be added in future commits.
19 lines
603 B
Dart
19 lines
603 B
Dart
import "dart:async";
|
|
import "package:fast_immutable_collections/fast_immutable_collections.dart";
|
|
import "package:flutter_riverpod/flutter_riverpod.dart";
|
|
|
|
class MultiProviderController extends AsyncNotifier<void> {
|
|
MultiProviderController(this.providers);
|
|
final IList<AsyncNotifierProvider> providers;
|
|
|
|
@override
|
|
Future<void> build() =>
|
|
.wait(providers.map((provider) => ref.watch(provider.future)));
|
|
|
|
static final provider =
|
|
AsyncNotifierProvider.family<
|
|
MultiProviderController,
|
|
void,
|
|
IList<AsyncNotifierProvider>
|
|
>(MultiProviderController.new);
|
|
}
|