From 0a2b09589c006588b8d879e2efa2e2eb7ad68c19 Mon Sep 17 00:00:00 2001 From: Lyle Dean Date: Tue, 8 Jun 2021 16:57:22 +0100 Subject: [PATCH 1/3] Add flavour support --- README.md | 6 ++++++ bin/create.dart | 8 ++++++-- bin/remove.dart | 8 ++++++-- lib/flutter_native_splash.dart | 8 ++++---- pubspec.yaml | 1 + 5 files changed, 23 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index dc0862d..dd8a369 100644 --- a/README.md +++ b/README.md @@ -111,6 +111,12 @@ flutter pub run flutter_native_splash:create When the package finishes running, your splash screen is ready. +For different flavors or to specify the yaml file location, just add the following path with the command + +``` +flutter pub run flutter_native_splash:create --path=path/to/my/file.yaml +``` + # Recommendations ## Secondary splash screen: The native splash screen is displayed while the native app loads the Flutter framework. Once Flutter loads, there may still be resources that need to be loaded before your app is ready. For this reason, you should consider implementing a Flutter splash screen that is displayed while these resources load. Here is a code example of a secondary Flutter splash screen, or use a package from [pub.dev](https://pub.dev). diff --git a/bin/create.dart b/bin/create.dart index b716833..4efa854 100644 --- a/bin/create.dart +++ b/bin/create.dart @@ -1,6 +1,10 @@ +import 'package:args/args.dart'; import 'package:flutter_native_splash/flutter_native_splash.dart' as flutter_native_splash; -void main(List arguments) { - flutter_native_splash.createSplash(); +void main(List args) { + var parser = ArgParser(); + parser.addOption('path', + callback: (path) => {flutter_native_splash.createSplash(path)}); + parser.parse(args); } diff --git a/bin/remove.dart b/bin/remove.dart index 5980ef2..3786011 100644 --- a/bin/remove.dart +++ b/bin/remove.dart @@ -1,6 +1,10 @@ +import 'package:args/args.dart'; import 'package:flutter_native_splash/flutter_native_splash.dart' as flutter_native_splash; -void main(List arguments) { - flutter_native_splash.removeSplash(); +void main(List args) { + var parser = ArgParser(); + parser.addOption('path', + callback: (path) => {flutter_native_splash.removeSplash(path)}); + parser.parse(args); } diff --git a/lib/flutter_native_splash.dart b/lib/flutter_native_splash.dart index 45c47b6..c6d7b84 100644 --- a/lib/flutter_native_splash.dart +++ b/lib/flutter_native_splash.dart @@ -16,8 +16,8 @@ part 'templates.dart'; part 'web.dart'; /// Create splash screens for Android and iOS -void createSplash() { - var config = getConfig(); +void createSplash(String? path) { + var config = getConfig(configFile: path); checkConfig(config); createSplashByConfig(config); } @@ -83,9 +83,9 @@ void createSplashByConfig(Map config) { } /// Remove any splash screen by setting the default white splash -void removeSplash() { +void removeSplash(String? path) { print('Restoring Flutter\'s default white native splash screen...'); - var config = getConfig(); + var config = getConfig(configFile: path); var removeConfig = {'color': '#ffffff'}; if (config.containsKey('android')) { diff --git a/pubspec.yaml b/pubspec.yaml index cbcfa3a..1e1da57 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -7,6 +7,7 @@ environment: sdk: '>=2.12.0 <3.0.0' dependencies: + args: ^2.1.1 image: ^3.0.2 meta: ^1.3.0 path: ^1.8.0 From e935c3029e680ed8518d988d0dcb0e2bb7bcc4df Mon Sep 17 00:00:00 2001 From: Lyle Dean Date: Tue, 8 Jun 2021 17:30:29 +0100 Subject: [PATCH 2/3] Update args to 2.0.0 --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 1e1da57..1dabc8a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -7,7 +7,7 @@ environment: sdk: '>=2.12.0 <3.0.0' dependencies: - args: ^2.1.1 + args: ^2.0.0 image: ^3.0.2 meta: ^1.3.0 path: ^1.8.0 From 4b46359d5a3aff51af06c080d108aedaa3f417ee Mon Sep 17 00:00:00 2001 From: Lyle Dean Date: Tue, 8 Jun 2021 20:36:45 +0100 Subject: [PATCH 3/3] Update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dd8a369..46942be 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,7 @@ flutter pub run flutter_native_splash:create When the package finishes running, your splash screen is ready. -For different flavors or to specify the yaml file location, just add the following path with the command +To specify the yaml file location just add --path with the command in the terminal: ``` flutter pub run flutter_native_splash:create --path=path/to/my/file.yaml