mirror of
https://github.com/Iconica-Development/flutter_start.git
synced 2025-05-18 18:13:45 +02:00
feat: added after splash route
This commit is contained in:
parent
cdf53e9afa
commit
4f322cb4a3
4 changed files with 15 additions and 8 deletions
|
@ -1,3 +1,7 @@
|
|||
## 2.0.3
|
||||
|
||||
- Added after splashscreen route
|
||||
|
||||
## 2.0.2
|
||||
|
||||
- Added configuration options
|
||||
|
|
|
@ -63,5 +63,5 @@ class StartUserStoryConfiguration {
|
|||
final int minimumSplashScreenDuration;
|
||||
|
||||
/// The future that is awaited before the splash screen is closed.
|
||||
final Future<void> Function(BuildContext context)? splashScreenFuture;
|
||||
final Future<String?> Function(BuildContext context)? splashScreenFuture;
|
||||
}
|
||||
|
|
|
@ -24,11 +24,10 @@ List<GoRoute> getStartStoryRoutes(
|
|||
var go = context.go;
|
||||
var killSwitchIsActive = false;
|
||||
var introductionSeen = false;
|
||||
Future<void> myFunction() async {
|
||||
String? routeAfterSplash;
|
||||
Future<void> splashLoadingMethod() async {
|
||||
await Future.wait<void>(
|
||||
[
|
||||
configuration.splashScreenFuture?.call(context) ??
|
||||
Future.value(),
|
||||
Future.delayed(
|
||||
Duration.zero,
|
||||
() async {
|
||||
|
@ -40,6 +39,10 @@ List<GoRoute> getStartStoryRoutes(
|
|||
SharedPreferencesIntroductionDataProvider(),
|
||||
);
|
||||
introductionSeen = !await introService.shouldShow();
|
||||
if (context.mounted)
|
||||
routeAfterSplash = await configuration.splashScreenFuture
|
||||
?.call(context) ??
|
||||
configuration.homeScreenRoute;
|
||||
},
|
||||
),
|
||||
Future.delayed(
|
||||
|
@ -56,21 +59,21 @@ List<GoRoute> 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,
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue