import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:syncrow_web/pages/auth/bloc/auth_bloc.dart'; import 'package:syncrow_web/pages/home/bloc/home_bloc.dart'; import 'package:syncrow_web/pages/visitor_password/bloc/visitor_password_bloc.dart'; import 'package:go_router/go_router.dart'; import 'package:syncrow_web/services/locator.dart'; import 'package:syncrow_web/utils/app_routes.dart'; import 'package:syncrow_web/utils/color_manager.dart'; import 'package:syncrow_web/utils/constants/routes_const.dart'; Future main() async { WidgetsFlutterBinding.ensureInitialized(); initialSetup(); String checkToken = await AuthBloc.getTokenAndValidate(); GoRouter router = GoRouter( initialLocation: checkToken == 'Success' ? RoutesConst.home : RoutesConst.auth, routes: AppRoutes.getRoutes(), ); runApp(MyApp( router: router, )); } class MyApp extends StatelessWidget { final GoRouter router; const MyApp({ super.key, required this.router, }); @override Widget build(BuildContext context) { return MultiBlocProvider( providers: [ BlocProvider(create: (context) => HomeBloc()), BlocProvider( create: (context) => VisitorPasswordBloc(), ) ], child: MaterialApp.router( debugShowCheckedModeBanner: false, // Hide debug banner scrollBehavior: const MaterialScrollBehavior().copyWith( dragDevices: { PointerDeviceKind.mouse, PointerDeviceKind.touch, PointerDeviceKind.stylus, PointerDeviceKind.unknown, }, ), theme: ThemeData( fontFamily: 'Aftika', textTheme: const TextTheme( bodySmall: TextStyle( fontSize: 13, color: ColorsManager.whiteColors, fontWeight: FontWeight.bold), bodyMedium: TextStyle(color: Colors.black87, fontSize: 14), bodyLarge: TextStyle(fontSize: 16, color: Colors.white), headlineSmall: TextStyle(color: Colors.black87, fontSize: 18), headlineMedium: TextStyle(color: Colors.black87, fontSize: 20), headlineLarge: TextStyle( color: Colors.white, fontSize: 24, fontWeight: FontWeight.bold, ), ), ), routeInformationProvider: router.routeInformationProvider, routerDelegate: router.routerDelegate, routeInformationParser: router.routeInformationParser, )); } }