I am using MSAL to authenticate users, with a ChangeNotifierProvider. I am trying to navigate to another page from the MSAL login but Navigator.push needs to be used in a widget. How do i navigate to another page without using Navigator.push? Or is it not available for flutter?
Code below:
void main() => runApp(
MultiProvider(
providers: [
ChangeNotifierProvider(create: (_) => MsalProvider())
],
child: MyApp(),
)
);
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return CupertinoApp(
home: Consumer(
builder: (BuildContext context, MsalProvider msal, Widget _){
// print(msal.status);
switch(msal.status){
case AuthStatus.AUTHENTICATED_USER:
return MaterialPageRoute(builder: (context)=> UASRegistered()); // does not work, error says need a widget
}
}
));
}
}