I am a beginner in mobile development using Flutter, and I want to set up role-based routing for my app by creating a separate routing file in Dart. My app uses JWT authentication, and the token is already stored locally. However, this is my first time implementing role-based access, and I am not sure how to proceed.
How can I set up role-based routing in Flutter based on the user's role from the JWT token? Any guidance or examples would be greatly appreciated!
here is how i have been managing the routing for the app :
import 'package:flutter/material.dart';
import 'package:stockhive_mobile/screen/admin/departements/Departmentad.dart';
import 'package:stockhive_mobile/screen/admin/users/adduser.dart';
import 'package:stockhive_mobile/screen/auth/introduction_page.dart';
import 'package:stockhive_mobile/screen/auth/login_page.dart';
import 'package:stockhive_mobile/screen/auth/resetpassword.dart';
import 'package:stockhive_mobile/screen/auth/otp.dart';
import 'package:stockhive_mobile/screen/auth/newpassword.dart';
import 'package:stockhive_mobile/screen/auth/editprofile.dart';
import 'package:stockhive_mobile/screen/auth/onboarding.dart';
import 'package:stockhive_mobile/screen/auth/viewprofile.dart';
import 'package:stockhive_mobile/splash/splash_screen.dart';
import '../admin/departements/adddepartementscreen.dart';
import '../admin/users/userscreen.dart';
import 'AdminRoutes.dart'; // Import Admin Routes
import 'collaborator_routes.dart'; // Import Collaborator Routes
import 'package:jwt_decoder/jwt_decoder.dart';
class AppRouter {
static const String introRoute = '/intro';
static const String loginRoute = '/login';
static const String onboardingRoute = '/onboarding';
static const String resetPasswordRoute = '/fetpassword';
static const String otpRoute = '/otp';
static const String newPasswordRoute = '/newpassword';
static const String editProfileRoute = '/editprofile';
static const String viewProfileRoute = '/viewprofile';
static const String usersRoute = '/usersad';
static const String adduserRoute = '/adduser';
static const String departmentsRoute = '/department';
static const String adddepartmentRoute = '/adddepartment';
static const String infodepartmentRoute = '/infodepartment';
static const String materielsRoute = '/materiel';
static const String addmaterielRoute = '/addmateriel';
/*static const String infomaterielRoute = '/infomateriel';
static const String dashboardRoute = '/dashboard';*/
static const String splashRoute = '/splash';
static Route<dynamic> generateRoute(RouteSettings settings) {
print('