Skip to content

Instantly share code, notes, and snippets.

@rrousselGit
Created March 5, 2020 22:34
Show Gist options
  • Save rrousselGit/4e23651a50cc1225ff59ed82c59e4924 to your computer and use it in GitHub Desktop.
Save rrousselGit/4e23651a50cc1225ff59ed82c59e4924 to your computer and use it in GitHub Desktop.
class Something with ChangeNotifier {
bool hasCompletedSomething;
}
class SomethingElse with ChangeNotifier {
bool hasCompletedSomething;
}
class Loading {
Loading(this.value);
final bool value;
}
void main() {
runApp(
MultiProvider(
providers: [
ChangeNotifierProvider(create: (_) => Something()),
ChangeNotifierProvider(create: (_) => SomethingElse()),
ProxyProvider0<Loading>(
update: (context, _) {
return Loading(
context.watch<Something>().hasCompletedSomething &&
context.watch<SomethingElse>().hasCompletedSomething,
);
},
),
],
child: MyApp(),
),
);
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
if (context.watch<Loading>().value) {
return const CircularProgressIndicator();
}
return MaterialApp(
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment