diff --git a/analysis_options.yaml b/analysis_options.yaml index f898260f78..1421ef5bcb 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -20,6 +20,7 @@ analyzer: - "lib/src/http/**" - "example/**" - "**/*.g.dart" + - "lib/src/version.dart" linter: rules: diff --git a/lib/abs/icon_generator.dart b/lib/abs/icon_generator.dart index 8e70a9d2b4..8d8288b384 100644 --- a/lib/abs/icon_generator.dart +++ b/lib/abs/icon_generator.dart @@ -111,7 +111,7 @@ void generateIconsFor({ } } } catch (e, st) { - // todo: better error handling + // TODO(RatakondalaArun): better error handling // stacktrace should only print when verbose is turned on // else a normal help line logger diff --git a/lib/android.dart b/lib/android.dart index eade1dcdb2..f055d6ca43 100644 --- a/lib/android.dart +++ b/lib/android.dart @@ -1,3 +1,5 @@ +// ignore_for_file: public_member_api_docs + import 'dart:io'; import 'package:flutter_launcher_icons/constants.dart'; @@ -37,7 +39,7 @@ void createDefaultIcons( String? flavor, ) { utils.printStatus('Creating default icons Android'); - // todo: support prefixPath + // TODO(p-mazhnik): support prefixPath final String? filePath = flutterLauncherIconsConfig.getImagePathAndroid(); if (filePath == null) { throw const InvalidConfigException(errorMissingImagePath); @@ -139,7 +141,8 @@ void updateColorsXmlFile(String backgroundConfig, String? flavor) { final File colorsXml = File(constants.androidColorsFile(flavor)); if (colorsXml.existsSync()) { utils.printStatus( - 'Updating colors.xml with color for adaptive icon background'); + 'Updating colors.xml with color for adaptive icon background', + ); updateColorsFile(colorsXml, backgroundConfig); } else { utils.printStatus('No colors.xml file found in your Android project'); diff --git a/lib/constants.dart b/lib/constants.dart index 897f4230b3..9f51dab39b 100644 --- a/lib/constants.dart +++ b/lib/constants.dart @@ -1,3 +1,5 @@ +// ignore_for_file: public_member_api_docs + import 'package:path/path.dart' as path; /// Relative path to android resource folder @@ -44,7 +46,7 @@ String webIconsDirPath = path.join(webDirPath, 'icons'); /// Relative web manifest.json file path String webManifestFilePath = path.join(webDirPath, 'manifest.json'); -// todo: support for other images formats +// TODO(RatakondalaArun): support for other images formats /// Relative favicon.png path String webFaviconFilePath = path.join(webDirPath, 'favicon.png'); diff --git a/lib/custom_exceptions.dart b/lib/custom_exceptions.dart index 82cbe2b746..926be69d54 100644 --- a/lib/custom_exceptions.dart +++ b/lib/custom_exceptions.dart @@ -1,7 +1,10 @@ import 'package:flutter_launcher_icons/utils.dart'; -class InvalidAndroidIconNameException implements Exception { - const InvalidAndroidIconNameException([this.message]); +/// Exception to be thrown whenever we have an invalid configuration +class InvalidConfigException implements Exception { + /// Constructs instance + const InvalidConfigException([this.message]); + /// Message for the exception final String? message; @override @@ -10,8 +13,11 @@ class InvalidAndroidIconNameException implements Exception { } } -class InvalidConfigException implements Exception { - const InvalidConfigException([this.message]); +/// Exception to be thrown whenever using an invalid Android icon name +class InvalidAndroidIconNameException implements Exception { + /// Constructs instance of this exception + const InvalidAndroidIconNameException([this.message]); + /// Message for the exception final String? message; @override @@ -20,8 +26,11 @@ class InvalidConfigException implements Exception { } } +/// Exception to be thrown whenever no config is found class NoConfigFoundException implements Exception { + /// Constructs instance of this exception const NoConfigFoundException([this.message]); + /// Message for the exception final String? message; @override @@ -30,8 +39,11 @@ class NoConfigFoundException implements Exception { } } +/// Exception to be thrown whenever there is no decoder for the image format class NoDecoderForImageFormatException implements Exception { + /// Constructs instance of this exception const NoDecoderForImageFormatException([this.message]); + /// Message for the exception final String? message; @override diff --git a/lib/flutter_launcher_icons_config.dart b/lib/flutter_launcher_icons_config.dart index 0f9dcf3553..4f863291fb 100644 --- a/lib/flutter_launcher_icons_config.dart +++ b/lib/flutter_launcher_icons_config.dart @@ -82,6 +82,7 @@ class FlutterLauncherIconsConfig { factory FlutterLauncherIconsConfig.fromJson(Map json) => _$FlutterLauncherIconsConfigFromJson(json); + /// whether or not there is configuration for adaptive icons for android bool get hasAndroidAdaptiveConfig => isNeedingNewAndroidIcon && adaptiveIconForeground != null && @@ -101,16 +102,20 @@ class FlutterLauncherIconsConfig { /// bool - override the default flutter project icon bool get isCustomAndroidFile => android is String; + /// if we are needing a new Android icon bool get isNeedingNewAndroidIcon => android != false; + /// if we are needing a new iOS icon bool get isNeedingNewIOSIcon => ios != false; /// Method for the retrieval of the Android icon path /// If image_path_android is found, this will be prioritised over the image_path /// value. String? getImagePathAndroid() => imagePathAndroid ?? imagePath; - // todo: refactor after Android & iOS configs will be refactored to the new schema + + // TODO(RatakondalaArun): refactor after Android & iOS configs will be refactored to the new schema // https://github.com/fluttercommunity/flutter_launcher_icons/issues/394 + /// get the image path for IOS String? getImagePathIOS() => imagePathIOS ?? imagePath; /// Converts config to [Map] @@ -144,7 +149,7 @@ class FlutterLauncherIconsConfig { return yaml.checkedYamlDecode( configContent, (json) { - // todo: add support for new scheme https://github.com/fluttercommunity/flutter_launcher_icons/issues/373 + // TODO(RatakondalaArun): add support for new scheme https://github.com/fluttercommunity/flutter_launcher_icons/issues/373 return json == null || json['flutter_icons'] == null ? null : FlutterLauncherIconsConfig.fromJson(json['flutter_icons']); @@ -169,7 +174,7 @@ class FlutterLauncherIconsConfig { return yaml.checkedYamlDecode( pubspecContent, (json) { - // todo: add support for new scheme https://github.com/fluttercommunity/flutter_launcher_icons/issues/373 + // TODO(RatakondalaArun): add support for new scheme https://github.com/fluttercommunity/flutter_launcher_icons/issues/373 return json == null || json['flutter_icons'] == null ? null : FlutterLauncherIconsConfig.fromJson(json['flutter_icons']); diff --git a/lib/ios.dart b/lib/ios.dart index 8edbbb31bc..bc341e9ade 100644 --- a/lib/ios.dart +++ b/lib/ios.dart @@ -1,3 +1,5 @@ +// ignore_for_file: public_member_api_docs + import 'dart:convert'; import 'dart:io'; @@ -9,12 +11,16 @@ import 'package:image/image.dart'; /// File to handle the creation of icons for iOS platform class IosIconTemplate { + /// constructs an instance of [IosIconTemplate] IosIconTemplate({required this.size, required this.name}); + /// suffix of the icon name final String name; + /// the size of the icon final int size; } +/// details of the ios icons which need to be generated List iosIcons = [ IosIconTemplate(name: '-20x20@1x', size: 20), IosIconTemplate(name: '-20x20@2x', size: 40), @@ -39,8 +45,9 @@ List iosIcons = [ IosIconTemplate(name: '-1024x1024@1x', size: 1024), ]; +/// create the ios icons void createIcons(FlutterLauncherIconsConfig config, String? flavor) { - // todo: support prefixPath + // TODO(p-mazhnik): support prefixPath final String? filePath = config.getImagePathIOS(); if (filePath == null) { throw const InvalidConfigException(errorMissingImagePath); @@ -116,6 +123,7 @@ void saveNewIcons(IosIconTemplate template, Image image, String newIconName) { }); } +/// create resized icon image Image createResizedImage(IosIconTemplate template, Image image) { if (image.width >= template.size) { return copyResize( @@ -134,6 +142,7 @@ Image createResizedImage(IosIconTemplate template, Image image) { } } +/// Change the iOS launcher icon Future changeIosLauncherIcon(String iconName, String? flavor) async { final File iOSConfigFile = File(iosConfigFile); final List lines = await iOSConfigFile.readAsLines(); @@ -186,6 +195,7 @@ String generateContentsFileAsString(String newIconName) { return json.encode(contentJson); } + class ContentsImageObject { ContentsImageObject({ required this.size, diff --git a/lib/main.dart b/lib/main.dart index 1ac232b3a7..3e65f45c25 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,3 +1,5 @@ +// ignore_for_file: public_member_api_docs + import 'dart:io'; import 'package:args/args.dart'; @@ -14,6 +16,7 @@ import 'package:flutter_launcher_icons/web/web_icon_generator.dart'; import 'package:flutter_launcher_icons/windows/windows_icon_generator.dart'; import 'package:path/path.dart' as path; + const String fileOption = 'file'; const String helpFlag = 'help'; const String verboseFlag = 'verbose'; @@ -153,7 +156,7 @@ Future createIconsFromConfig( WebIconGenerator(context), WindowsIconGenerator(context), MacOSIconGenerator(context), - // todo: add other platforms + // TODO(RatakondalaArun): add other platforms ], ); } diff --git a/lib/utils.dart b/lib/utils.dart index 98824815f6..8a35d88c45 100644 --- a/lib/utils.dart +++ b/lib/utils.dart @@ -1,3 +1,5 @@ +// ignore_for_file: public_member_api_docs + import 'dart:convert'; import 'dart:io'; diff --git a/lib/web/web_icon_generator.dart b/lib/web/web_icon_generator.dart index f3567e5d8e..ebc60694ed 100644 --- a/lib/web/web_icon_generator.dart +++ b/lib/web/web_icon_generator.dart @@ -75,7 +75,7 @@ class WebIconGenerator extends IconGenerator { ); _updateManifestFile(); - // todo: update index.html in web/index.html + // TODO(RatakondalaArun): update index.html in web/index.html // as we are using flutter default config we no need // to update index.html for now // _updateIndexFile(); @@ -138,14 +138,6 @@ class WebIconGenerator extends IconGenerator { } } - // void _updateIndexFile() { - // todo - // final indexFile = File(constants.webIndexFilePath); - // if (!indexFile.existsSync()) { - // throw FileNotFoundException(constants.webFaviconFilePath); - // } - // } - void _updateManifestFile() { final manifestFile = utils.createFileIfNotExist( path.join(context.prefixPath, constants.webManifestFilePath), diff --git a/lib/xml_templates.dart b/lib/xml_templates.dart index 0ece2e87b9..9f6282e148 100644 --- a/lib/xml_templates.dart +++ b/lib/xml_templates.dart @@ -1,3 +1,5 @@ +// ignore_for_file: public_member_api_docs + const String icLauncherXml = '''