I have my main.dart as follows:
child: MaterialApp(
title: Constants.appTitle,
theme: ThemeData(
primarySwatch: Colors.blue,
fontFamily: Constants.fontSansFrancisco,
),
home: AuthScreen(),
debugShowCheckedModeBanner: false,
onGenerateRoute: _appRouter.onGenerateRoute,
),
How can I change my home to DashboardScreen() instead of AuthScreen() using a async function returning a future value:
Future<String?> getSession() => storage.read(key: "token");
I want to change home to DashboardScreen() if getSession() returns a non-empty string.
CodePudding user response:
You can have a splash screen that in splash's initState function or controller class get token and then Decision what page you want to open.
Or do this in AuthScreen class.
