55 lines
1.6 KiB
Dart
55 lines
1.6 KiB
Dart
import 'dart:async';
|
|
import 'package:barcode_scanner/pages/login_page/login_page.dart';
|
|
import 'package:barcode_scanner/pages/login_page/login_page_model.dart';
|
|
import 'package:barcode_scanner/pages/splash_page/splash_page.dart';
|
|
import 'package:barcode_scanner/provider_container.dart';
|
|
import 'package:barcode_scanner/router/go_secure_router_builder.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
export 'package:go_router/go_router.dart';
|
|
|
|
part 'go_router_builder.g.dart';
|
|
|
|
final appRoutes = $appRoutes;
|
|
|
|
const String _loginPage = 'LoginPage';
|
|
const String _splashPage = 'SplashPage';
|
|
const String _notFound = 'not_found';
|
|
|
|
@TypedGoRoute<SplashRoute>(path: '/$_splashPage')
|
|
class SplashRoute extends GoRouteData with _$SplashRoute {
|
|
const SplashRoute();
|
|
|
|
// @override
|
|
// String? redirect(BuildContext context, GoRouterState state) {
|
|
// final isLogged = providerContainer
|
|
// .read(loginPageModelProvider)
|
|
// .status
|
|
// .isLogged;
|
|
// if (isLogged) {
|
|
// return HomeRoute().location;
|
|
// } else {
|
|
// return LoginRoute().location;
|
|
// }
|
|
// }
|
|
|
|
@override
|
|
Widget build(BuildContext context, GoRouterState state) => SplashPage();
|
|
}
|
|
|
|
@TypedGoRoute<LoginRoute>(path: '/$_loginPage')
|
|
class LoginRoute extends GoRouteData with _$LoginRoute {
|
|
const LoginRoute();
|
|
|
|
@override
|
|
Widget build(BuildContext context, GoRouterState state) => LoginPage();
|
|
}
|
|
|
|
@TypedGoRoute<NotFoundRoute>(path: '/$_notFound')
|
|
class NotFoundRoute extends GoRouteData with _$NotFoundRoute {
|
|
const NotFoundRoute();
|
|
|
|
@override
|
|
Widget build(BuildContext context, GoRouterState state) => SizedBox();
|
|
}
|