【发布时间】:2021-03-01 10:45:23
【问题描述】:
首先在主函数中,我想从存储中获取数据并检查它们,以便在用户未登录时阻止一些路由
我使用 JWT 和一些 AuthData 来检查应用程序运行时令牌是否过期
void main() => {
var authData = await TokenStorageService.authDataOrEmpty;
runApp(
MaterialApp(
title: 'routes',
theme: ThemeData(
scaffoldBackgroundColor: Color(0xFFF1F1F1),
),
initialRoute: '/', // Start the app with the "/" named route.
routes: {
'/': (context) => HomePage(),
// build the HomePage widget.
WelcomeScreen.id: (context) => WelcomeScreen(),
Profile.id: (context) => Profile(),
//build welcome screen
LoginScreen.id: (context) => LoginScreen(),
// build the Login widget.
RegistrationScreen.id: (context) => RegistrationScreen(),
// build the Register widget.
'/userLeave': (context) => UserLeave(),
// build the UserLeave widget.
'/leaveRequest': (context) => LeaveRequest(),
// build the LeaveRequest widget.
'/ownLeave': (context) => OwnLeave(),
// build the LeaveRequest widget.
'/allLeaves': (context) => AllLeave(),
// build the LeaveRequest widget.
},
),
)
};
【问题讨论】:
标签: flutter dart flutter-dependencies