NavigationLogic constructor
NavigationLogic({
- Widget defaultLoading()?,
- required BuildContext context,
- required Widget initialScreen(),
- required PathsBuilder rootPaths,
- Stream? authState,
- FeatureAccessController? featureAccessController,
Creates a new NavigationLogic instance.
Throws an exception if more than one instance is attempted to be created.
Implementation
NavigationLogic({
this.defaultLoading,
required this.context,
required this.initialScreen,
required this.rootPaths,
this.authState,
this.featureAccessController,
}) : _currentScreen = initialScreen() {
_routePath = rootPaths.bareBuilder('', initialScreen)();
routerDelegate = StandardRouterDelegate(context, this);
routerInformationParser = StandardRouteInformationParser(rootPaths);
final authState = this.authState;
rootPaths.accessDeniedRoute ??= _defaultAccessDeniedRoute();
if (!_navigationLogicInitialised) {
GetIt.instance.registerSingleton(this);
_navigationLogicInitialised = true;
} else {
throw Exception('Only one instance of NavigationLogic can be created');
}
defaultLoading ??= () => const DefaultLoading();
if (authState != null) {
_onAuthStateChangedSubscription = authState.listen(_onAuthStateChanged);
} else {
_isInitialising = false;
}
if (!DirtyStateMonitor.isInitialised) {
DirtyStateMonitor.initialise();
}
}