Skip to content

Commit

Permalink
Add Command Line Path To Config File (#180)
Browse files Browse the repository at this point in the history
Add Command Line Path To Config File
  • Loading branch information
lyledean1 committed Jun 9, 2021
1 parent c8bf110 commit 5db4628
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -111,6 +111,12 @@ flutter pub run flutter_native_splash:create

When the package finishes running, your splash screen is ready.

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

# 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).
Expand Down
8 changes: 6 additions & 2 deletions 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<String> arguments) {
flutter_native_splash.createSplash();
void main(List<String> args) {
var parser = ArgParser();
parser.addOption('path',
callback: (path) => {flutter_native_splash.createSplash(path)});
parser.parse(args);
}
8 changes: 6 additions & 2 deletions 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<String> arguments) {
flutter_native_splash.removeSplash();
void main(List<String> args) {
var parser = ArgParser();
parser.addOption('path',
callback: (path) => {flutter_native_splash.removeSplash(path)});
parser.parse(args);
}
8 changes: 4 additions & 4 deletions lib/flutter_native_splash.dart
Expand Up @@ -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);
}
Expand Down Expand Up @@ -83,9 +83,9 @@ void createSplashByConfig(Map<String, dynamic> 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 = <String, dynamic>{'color': '#ffffff'};
if (config.containsKey('android')) {
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Expand Up @@ -7,6 +7,7 @@ environment:
sdk: '>=2.12.0 <3.0.0'

dependencies:
args: ^2.0.0
image: ^3.0.2
meta: ^1.3.0
path: ^1.8.0
Expand Down

0 comments on commit 5db4628

Please sign in to comment.