diff --git a/example/lib/main.dart b/example/lib/main.dart index 4d503ed..0a1ed31 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -24,11 +24,22 @@ class Home extends StatelessWidget { startNavigatorUserStory(config, context); } +final _router = GoRouter( + initialLocation: '/splashScreen', + routes: [ + ...getStartRoutes(), + ], +); + List getStartRoutes() => getStartStoryRoutes( config, ); StartUserStoryConfiguration config = StartUserStoryConfiguration( + introductionService: IntroductionService( + ExampleIntroductionDataProvider(), + ), + useKillswitch: true, // showIntroduction: false, splashScreenBuilder: (context, onFinish) => SplashScreen( onFinish: onFinish, diff --git a/lib/src/user_stories/flutter_start_userstory_go_router.dart b/lib/src/user_stories/flutter_start_userstory_go_router.dart index e4d8f78..2557c29 100644 --- a/lib/src/user_stories/flutter_start_userstory_go_router.dart +++ b/lib/src/user_stories/flutter_start_userstory_go_router.dart @@ -22,7 +22,7 @@ List getStartStoryRoutes( path: StartUserStoryRoutes.splashScreen, pageBuilder: (context, state) { var go = context.go; - var killSwitchIsActive = false; + var isAllowedToPassThrough = false; var introductionSeen = false; Future myFunction() async { await Future.wait( @@ -33,7 +33,7 @@ List getStartStoryRoutes( Duration.zero, () async { if (configuration.useKillswitch) - killSwitchIsActive = + isAllowedToPassThrough = await KillswitchService().isKillswitchActive(); var introService = configuration.introductionService ?? IntroductionService( @@ -51,7 +51,7 @@ List getStartStoryRoutes( ], ); - if (configuration.useKillswitch && killSwitchIsActive) return; + if (configuration.useKillswitch && !isAllowedToPassThrough) return; if (!configuration.showIntroduction || (introductionSeen && !configuration.alwaysShowIntroduction)) { @@ -114,4 +114,17 @@ List getStartStoryRoutes( ); }, ), + GoRoute( + path: StartUserStoryRoutes.home, + pageBuilder: (context, state) { + var home = configuration.homeEntry; + return buildScreenWithoutTransition( + context: context, + state: state, + child: Scaffold( + body: home, + ), + ); + }, + ), ]; diff --git a/lib/src/user_stories/flutter_start_userstory_navigator.dart b/lib/src/user_stories/flutter_start_userstory_navigator.dart index 2945839..33d0bd8 100644 --- a/lib/src/user_stories/flutter_start_userstory_navigator.dart +++ b/lib/src/user_stories/flutter_start_userstory_navigator.dart @@ -19,7 +19,7 @@ Widget _splashScreen( BuildContext context, ) { var navigator = Navigator.of(context); - var killSwitchIsActive = false; + var isAllowedToPassThrough = false; var introductionSeen = false; Future myFunction() async { await Future.wait( @@ -29,7 +29,7 @@ Widget _splashScreen( Duration.zero, () async { if (configuration.useKillswitch) - killSwitchIsActive = + isAllowedToPassThrough = await KillswitchService().isKillswitchActive(); var introService = configuration.introductionService ?? IntroductionService( @@ -47,7 +47,7 @@ Widget _splashScreen( ], ); - if (configuration.useKillswitch && killSwitchIsActive) return; + if (configuration.useKillswitch && !isAllowedToPassThrough) return; if (!configuration.showIntroduction || (introductionSeen && !configuration.alwaysShowIntroduction)) {