diff --git a/CHANGELOG.md b/CHANGELOG.md index d876097..02a329c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.0.5 + +- Added canPopFromIntroduction to enable/disable popping from introduction screens + ## 2.0.4 - Removed `AlwaysShowIntroduction` option, changed naming of `isKillSwitchActive` to `isAllowedToPassThrough`. diff --git a/lib/src/models/start_configuration.dart b/lib/src/models/start_configuration.dart index 4dbf8c9..04e7800 100644 --- a/lib/src/models/start_configuration.dart +++ b/lib/src/models/start_configuration.dart @@ -18,6 +18,7 @@ class StartUserStoryConfiguration { this.splashScreenFuture, this.splashScreenCenterWidget, this.splashScreenBackgroundColor, + this.canPopFromIntroduction = true, }); /// You can use this to build your own splash screen. @@ -60,4 +61,7 @@ class StartUserStoryConfiguration { /// The future that is awaited before the splash screen is closed. final Future Function(BuildContext context)? splashScreenFuture; + + /// Allow popping from introduction, defaults to true + final bool canPopFromIntroduction; } 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 cd0dbec..8661a9e 100644 --- a/lib/src/user_stories/flutter_start_userstory_go_router.dart +++ b/lib/src/user_stories/flutter_start_userstory_go_router.dart @@ -103,16 +103,20 @@ List getStartStoryRoutes( physics: configuration.introductionScrollPhysics, child: configuration.introductionFallbackScreen, ); + return buildScreenWithoutTransition( context: context, state: state, - child: configuration.introductionBuilder?.call( - context, - introduction, - ) ?? - Scaffold( - body: introduction, - ), + child: PopScope( + canPop: configuration.canPopFromIntroduction, + child: configuration.introductionBuilder?.call( + context, + introduction, + ) ?? + Scaffold( + body: introduction, + ), + ), ); }, ), diff --git a/lib/src/user_stories/flutter_start_userstory_navigator.dart b/lib/src/user_stories/flutter_start_userstory_navigator.dart index 5a1965b..701a552 100644 --- a/lib/src/user_stories/flutter_start_userstory_navigator.dart +++ b/lib/src/user_stories/flutter_start_userstory_navigator.dart @@ -93,8 +93,11 @@ Widget _introduction( physics: configuration.introductionScrollPhysics, child: configuration.introductionFallbackScreen, ); - return Scaffold( - body: introduction, + return PopScope( + canPop: configuration.canPopFromIntroduction, + child: Scaffold( + body: introduction, + ), ); } diff --git a/pubspec.yaml b/pubspec.yaml index 75165af..ada11da 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.4 +version: 2.0.5 environment: sdk: ">=3.2.5 <4.0.0"