
Performs a comprehensive project rename from 'barcode_scanner' to 'e_scan' (or 'eScan' for user-facing labels). This update spans all relevant files, including: - Application IDs and bundle identifiers for Android, iOS, macOS, and Linux. - VS Code launch configurations. - Dart package import paths. - Project names and titles in `pubspec.yaml`, `README.md`, and platform-specific configurations (e.g., CMakeLists, Info.plist, AndroidManifest).
83 lines
2.3 KiB
Dart
83 lines
2.3 KiB
Dart
import 'package:e_scan/router/go_router_builder.dart' hide $appRoutes;
|
|
import 'package:e_scan/router/go_secure_router_builder.dart' hide $appRoutes;
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
|
|
|
|
final navigatorsRouteLocationsProvider = StateProvider<List<String>>(
|
|
(ref) => [],
|
|
);
|
|
|
|
final routerProvider = Provider<GoRouter>(
|
|
(ref) {
|
|
// ref.watch(authViewModelProvider);
|
|
|
|
return GoRouter(
|
|
debugLogDiagnostics: true,
|
|
routes: [...appRoutes, ...appSecureRoutes],
|
|
observers: [AppNavigatorObserver(ref: ref)],
|
|
navigatorKey: navigatorKey,
|
|
initialLocation: const ReceptionRoute().location,
|
|
errorBuilder: (context, state) {
|
|
// using a post frame callback to perform the navigation after
|
|
// the build frame has finished
|
|
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
|
const NotFoundRoute().go(context);
|
|
});
|
|
|
|
return const SizedBox.shrink();
|
|
},
|
|
);
|
|
},
|
|
dependencies: [
|
|
// authViewModelProvider,
|
|
],
|
|
);
|
|
|
|
class AppNavigatorObserver extends NavigatorObserver {
|
|
AppNavigatorObserver({required this.ref});
|
|
|
|
final Ref<GoRouter> ref;
|
|
|
|
@override
|
|
void didPush(Route<dynamic> route, Route<dynamic>? previousRoute) {
|
|
super.didPush(route, previousRoute);
|
|
_visitPage(route.settings.name);
|
|
}
|
|
|
|
@override
|
|
void didPop(Route<dynamic> route, Route<dynamic>? previousRoute) {
|
|
super.didPop(route, previousRoute);
|
|
_visitPage(previousRoute?.settings.name);
|
|
}
|
|
|
|
void _visitPage(String? location) {
|
|
if (location != null) {
|
|
if (location.startsWith('/')) {
|
|
Future.microtask(
|
|
() => ref.read(navigatorsRouteLocationsProvider.notifier).update((
|
|
state,
|
|
) {
|
|
final list = state..add(location);
|
|
return list.toList();
|
|
}),
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
CustomTransitionPage buildPageWithDefaultTransition<T>({
|
|
required BuildContext context,
|
|
required GoRouterState state,
|
|
required Widget child,
|
|
}) {
|
|
return CustomTransitionPage<T>(
|
|
key: state.pageKey,
|
|
child: child,
|
|
transitionsBuilder: (context, animation, secondaryAnimation, child) =>
|
|
FadeTransition(opacity: animation, child: child),
|
|
);
|
|
}
|