feat(introduction): add popscope for introduction screen

This commit is contained in:
FahadFahim71 2024-02-19 14:25:38 +01:00
parent d7a13f731e
commit 9d4c5c014f
5 changed files with 25 additions and 10 deletions

View file

@ -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`.

View file

@ -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<String?> Function(BuildContext context)? splashScreenFuture;
/// Allow popping from introduction, defaults to true
final bool canPopFromIntroduction;
}

View file

@ -103,9 +103,12 @@ List<GoRoute> getStartStoryRoutes(
physics: configuration.introductionScrollPhysics,
child: configuration.introductionFallbackScreen,
);
return buildScreenWithoutTransition(
context: context,
state: state,
child: PopScope(
canPop: configuration.canPopFromIntroduction,
child: configuration.introductionBuilder?.call(
context,
introduction,
@ -113,6 +116,7 @@ List<GoRoute> getStartStoryRoutes(
Scaffold(
body: introduction,
),
),
);
},
),

View file

@ -93,8 +93,11 @@ Widget _introduction(
physics: configuration.introductionScrollPhysics,
child: configuration.introductionFallbackScreen,
);
return Scaffold(
return PopScope(
canPop: configuration.canPopFromIntroduction,
child: Scaffold(
body: introduction,
),
);
}

View file

@ -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"