Created
March 5, 2020 22:34
-
-
Save rrousselGit/4e23651a50cc1225ff59ed82c59e4924 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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