diff --git a/CHANGELOG.md b/CHANGELOG.md index 203d78d..8efe74a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.0.3 + +- Added after splashscreen route + ## 2.0.2 - Added configuration options diff --git a/lib/src/models/start_configuration.dart b/lib/src/models/start_configuration.dart index 9c1bcc2..ef9d608 100644 --- a/lib/src/models/start_configuration.dart +++ b/lib/src/models/start_configuration.dart @@ -63,5 +63,5 @@ class StartUserStoryConfiguration { final int minimumSplashScreenDuration; /// The future that is awaited before the splash screen is closed. - final Future Function(BuildContext context)? splashScreenFuture; + final Future Function(BuildContext context)? splashScreenFuture; } 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..2d68823 100644 --- a/lib/src/user_stories/flutter_start_userstory_go_router.dart +++ b/lib/src/user_stories/flutter_start_userstory_go_router.dart @@ -24,11 +24,10 @@ List getStartStoryRoutes( var go = context.go; var killSwitchIsActive = false; var introductionSeen = false; - Future myFunction() async { + String? routeAfterSplash; + Future splashLoadingMethod() async { await Future.wait( [ - configuration.splashScreenFuture?.call(context) ?? - Future.value(), Future.delayed( Duration.zero, () async { @@ -40,6 +39,10 @@ List getStartStoryRoutes( SharedPreferencesIntroductionDataProvider(), ); introductionSeen = !await introService.shouldShow(); + if (context.mounted) + routeAfterSplash = await configuration.splashScreenFuture + ?.call(context) ?? + configuration.homeScreenRoute; }, ), Future.delayed( @@ -56,21 +59,21 @@ List getStartStoryRoutes( if (!configuration.showIntroduction || (introductionSeen && !configuration.alwaysShowIntroduction)) { return go( - configuration.homeScreenRoute ?? StartUserStoryRoutes.home, + routeAfterSplash ?? StartUserStoryRoutes.home, ); } return go(StartUserStoryRoutes.introduction); } if (configuration.splashScreenBuilder == null) { - unawaited(myFunction()); + unawaited(splashLoadingMethod()); } return buildScreenWithoutTransition( context: context, state: state, child: configuration.splashScreenBuilder?.call( context, - () async => myFunction(), + () async => splashLoadingMethod(), ) ?? Scaffold( backgroundColor: configuration.splashScreenBackgroundColor, diff --git a/pubspec.yaml b/pubspec.yaml index 9c7f3e1..7cc8783 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: flutter_start description: "Flutter_start is a package that allows you to jumpstart your application with a splashScreen, introduction and a home." publish_to: "none" -version: 2.0.2 +version: 2.0.3 environment: sdk: ">=3.2.5 <4.0.0"