forked from fluttercommunity/flutter_launcher_icons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
397ca81
commit 281edaa
Showing
45 changed files
with
967 additions
and
648 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:args/args.dart'; | ||
|
||
import 'package:flutter_launcher_icons/constants.dart'; | ||
import 'package:flutter_launcher_icons/src/version.dart'; | ||
|
||
const _defaultConfigFileName = './flutter_launcher_icons.yaml'; | ||
|
||
/// The function will be called from command line | ||
/// using the following command: | ||
/// ```sh | ||
/// flutter pub run flutter_launcher_icons:generate | ||
/// ``` | ||
/// | ||
/// Calling this function will generate a flutter_launcher_icons.yaml file | ||
/// with a default config template. | ||
/// | ||
/// This command can take 2 optional arguments: | ||
/// - --override: This will override the current `flutter_launcher_icons.yaml` | ||
/// file if it exists, if not provided, the file will not be overridden and | ||
/// a message will be printed to the console. | ||
/// | ||
/// - --fileName: This flag will take a file name as an argument and | ||
/// will generate the config format in that file instead of the default | ||
/// `flutter_launcher_icons.yaml` file, if not provided, | ||
/// the default file will be used. | ||
void main(List<String> arguments) { | ||
print(introMessage(packageVersion)); | ||
|
||
final parser = ArgParser() | ||
..addFlag('override', abbr: 'o', defaultsTo: false) | ||
..addOption( | ||
'fileName', | ||
abbr: 'f', | ||
defaultsTo: _defaultConfigFileName, | ||
); | ||
|
||
final results = parser.parse(arguments); | ||
final override = results['override'] as bool; | ||
final fileName = results['fileName'] as String; | ||
|
||
// Check if fileName is valid and has a .yaml extension | ||
if (!fileName.endsWith('.yaml')) { | ||
print('Invalid file name, please provide a valid file name'); | ||
return; | ||
} | ||
|
||
final file = File(fileName); | ||
if (file.existsSync()) { | ||
if (override) { | ||
print('File already exists, overriding...'); | ||
_generateConfigFile(file); | ||
} else { | ||
print( | ||
'File already exists, use --override flag to override the file, or use --fileName flag to use a different file name', | ||
); | ||
} | ||
} else { | ||
try { | ||
file.createSync(recursive: true); | ||
_generateConfigFile(file); | ||
} on Exception catch (e) { | ||
print('Error creating file: $e'); | ||
} | ||
} | ||
} | ||
|
||
void _generateConfigFile(File configFile) { | ||
try { | ||
configFile.writeAsStringSync(_configFileTemplate); | ||
|
||
print('\nConfig file generated successfully 🎉'); | ||
print( | ||
'You can now use this new config file by using the command below:\n\n' | ||
'flutter pub run flutter_launcher_icons' | ||
'${configFile.path == _defaultConfigFileName ? '' : ' -f ${configFile.path}'}\n', | ||
); | ||
} on Exception catch (e) { | ||
print('Error generating config file: $e'); | ||
} | ||
} | ||
|
||
const _configFileTemplate = ''' | ||
# flutter pub run flutter_launcher_icons | ||
flutter_launcher_icons: | ||
image_path: "assets/icon/icon.png" | ||
android: "launcher_icon" | ||
# image_path_android: "assets/icon/icon.png" | ||
min_sdk_android: 21 # android min sdk min:16, default 21 | ||
# adaptive_icon_background: "assets/icon/background.png" | ||
# adaptive_icon_foreground: "assets/icon/foreground.png" | ||
ios: true | ||
# image_path_ios: "assets/icon/icon.png" | ||
remove_alpha_channel_ios: true | ||
web: | ||
generate: true | ||
image_path: "path/to/image.png" | ||
background_color: "#hexcode" | ||
theme_color: "#hexcode" | ||
windows: | ||
generate: true | ||
image_path: "path/to/image.png" | ||
icon_size: 48 # min:48, max:256, default: 48 | ||
macos: | ||
generate: true | ||
image_path: "path/to/image.png" | ||
'''; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,45 @@ | ||
# This file tracks properties of this Flutter project. | ||
# Used by Flutter tool to assess capabilities and perform upgrades etc. | ||
# | ||
# This file should be version controlled and should not be manually edited. | ||
# This file should be version controlled. | ||
|
||
version: | ||
revision: ce40de69b7b4f89c66d19c8dbd3bd86ae30f1bc6 | ||
channel: dev | ||
revision: f72efea43c3013323d1b95cff571f3c1caa37583 | ||
channel: stable | ||
|
||
project_type: app | ||
|
||
# Tracks metadata for the flutter migrate command | ||
migration: | ||
platforms: | ||
- platform: root | ||
create_revision: f72efea43c3013323d1b95cff571f3c1caa37583 | ||
base_revision: f72efea43c3013323d1b95cff571f3c1caa37583 | ||
- platform: android | ||
create_revision: f72efea43c3013323d1b95cff571f3c1caa37583 | ||
base_revision: f72efea43c3013323d1b95cff571f3c1caa37583 | ||
- platform: ios | ||
create_revision: f72efea43c3013323d1b95cff571f3c1caa37583 | ||
base_revision: f72efea43c3013323d1b95cff571f3c1caa37583 | ||
- platform: linux | ||
create_revision: f72efea43c3013323d1b95cff571f3c1caa37583 | ||
base_revision: f72efea43c3013323d1b95cff571f3c1caa37583 | ||
- platform: macos | ||
create_revision: f72efea43c3013323d1b95cff571f3c1caa37583 | ||
base_revision: f72efea43c3013323d1b95cff571f3c1caa37583 | ||
- platform: web | ||
create_revision: f72efea43c3013323d1b95cff571f3c1caa37583 | ||
base_revision: f72efea43c3013323d1b95cff571f3c1caa37583 | ||
- platform: windows | ||
create_revision: f72efea43c3013323d1b95cff571f3c1caa37583 | ||
base_revision: f72efea43c3013323d1b95cff571f3c1caa37583 | ||
|
||
# User provided section | ||
|
||
# List of Local paths (relative to this file) that should be | ||
# ignored by the migrate tool. | ||
# | ||
# Files that are not part of the templates will be ignored by default. | ||
unmanaged_files: | ||
- 'lib/main.dart' | ||
- 'ios/Runner.xcodeproj/project.pbxproj' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
flutter_icons: | ||
flutter_launcher_icons: | ||
android: true | ||
ios: true | ||
image_path: "assets/launcher_icon/demo-icon-dev.png" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
flutter_icons: | ||
flutter_launcher_icons: | ||
android: true | ||
ios: true | ||
image_path: "assets/launcher_icon/demo-icon-int.png" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
flutter_icons: | ||
flutter_launcher_icons: | ||
android: true | ||
ios: true | ||
image_path: "assets/launcher_icon/demo-icon.png" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.