Currently I have a provider with 3 state Response (Success, Error, Running) and consumer which listening to this provider. Is it possible to push to another route, when response from provider is Success? Here is my consumer:
class SplashScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
body: _splashWidget(context),
);
}
Widget _splashWidget(BuildContext context) {
return Consumer<AccessTokenProvider>(builder: (context, myModel, child) {
switch (myModel.accessToken.status) {
case Status.COMPLETED:
Navigator.of(context).pushReplacementNamed(MainRoute);
return null;
case Status.ERROR:
return ErrorScreen();
default:
return SplashProcessing();
}
}, );
}
}
Is it a good case to make navigation in this way? Thanks!