mirror of
https://github.com/Iconica-Development/flutter_start.git
synced 2025-05-19 02:23:46 +02:00
Merge pull request #20 from Iconica-Development/19-rename-myfunction-in-the-splash-screen-handling-to-an-actual-proper-name
rename myfunction in the splash screen handling to an actual proper name
This commit is contained in:
commit
40d17eaf31
1 changed files with 30 additions and 17 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_start/flutter_start.dart';
|
import 'package:flutter_start/flutter_start.dart';
|
||||||
import 'package:flutter_start/src/services/killswitch_service.dart';
|
import 'package:flutter_start/src/services/killswitch_service.dart';
|
||||||
|
@ -19,9 +21,11 @@ Widget _splashScreen(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
) {
|
) {
|
||||||
var navigator = Navigator.of(context);
|
var navigator = Navigator.of(context);
|
||||||
|
|
||||||
var isAllowedToPassThrough = false;
|
var isAllowedToPassThrough = false;
|
||||||
var introductionSeen = false;
|
var introductionSeen = false;
|
||||||
Future<void> myFunction() async {
|
|
||||||
|
Future<void> splashHandler() async {
|
||||||
await Future.wait<void>(
|
await Future.wait<void>(
|
||||||
[
|
[
|
||||||
configuration.splashScreenFuture?.call(context) ?? Future.value(),
|
configuration.splashScreenFuture?.call(context) ?? Future.value(),
|
||||||
|
@ -42,14 +46,14 @@ Widget _splashScreen(
|
||||||
Duration(
|
Duration(
|
||||||
seconds: configuration.minimumSplashScreenDuration,
|
seconds: configuration.minimumSplashScreenDuration,
|
||||||
),
|
),
|
||||||
() async {},
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
if (configuration.useKillswitch && isAllowedToPassThrough) return;
|
if (configuration.useKillswitch && isAllowedToPassThrough) return;
|
||||||
|
|
||||||
if (!configuration.showIntroduction || introductionSeen) {
|
if ((!configuration.showIntroduction || introductionSeen) &&
|
||||||
|
context.mounted) {
|
||||||
await navigator.pushReplacement(
|
await navigator.pushReplacement(
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => _home(configuration, context),
|
builder: (context) => _home(configuration, context),
|
||||||
|
@ -57,18 +61,21 @@ Widget _splashScreen(
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (context.mounted) {
|
||||||
await navigator.pushReplacement(
|
await navigator.pushReplacement(
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => _introduction(configuration, context),
|
builder: (context) => _introduction(configuration, context),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return configuration.splashScreenBuilder?.call(
|
var builder = configuration.splashScreenBuilder;
|
||||||
context,
|
|
||||||
() async => myFunction(),
|
if (builder == null) {
|
||||||
) ??
|
unawaited(splashHandler());
|
||||||
Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: configuration.splashScreenBackgroundColor,
|
backgroundColor: configuration.splashScreenBackgroundColor,
|
||||||
body: Center(
|
body: Center(
|
||||||
child: configuration.splashScreenCenterWidget?.call(context) ??
|
child: configuration.splashScreenCenterWidget?.call(context) ??
|
||||||
|
@ -77,6 +84,12 @@ Widget _splashScreen(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return builder.call(
|
||||||
|
context,
|
||||||
|
splashHandler,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Widget _introduction(
|
Widget _introduction(
|
||||||
StartUserStoryConfiguration configuration,
|
StartUserStoryConfiguration configuration,
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
|
|
Loading…
Reference in a new issue