Skip to content

Commit

Permalink
fix(lint): filxed lint warnings for public_member_api_docs
Browse files Browse the repository at this point in the history
  • Loading branch information
RatakondalaArun committed Jul 20, 2022
1 parent 4aa4162 commit af10715
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 4 deletions.
1 change: 1 addition & 0 deletions analysis_options.yaml
Expand Up @@ -157,3 +157,4 @@ linter:
# - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review
- valid_regexps
# - void_checks # not yet tested
- public_member_api_docs
19 changes: 19 additions & 0 deletions lib/abs/icon_generator.dart
Expand Up @@ -5,9 +5,21 @@ import 'package:flutter_launcher_icons/logger.dart';

/// A base class to generate icons
abstract class IconGenerator {
/// Contains config
final IconGeneratorContext context;

/// Name of the platform this [IconGenerator] is created for.
final String platformName;

/// Creates a instance of [IconGenerator].
///
/// A [context] is created and provided by [generateIconsFor],
/// [platformName] takes the name of the platform that this [IconGenerator]
/// is implemented for
///
/// Also Refer
/// - [WebIconGenerator] generate icons for web
/// - [generateIconFor] generates icons for given platform
IconGenerator(this.context, this.platformName);

/// Creates icons for this platform.
Expand All @@ -23,10 +35,17 @@ abstract class IconGenerator {
class IconGeneratorContext {
/// Contains configuration from configuration file
final FlutterLauncherIconsConfig config;

/// A logger
final FLILogger logger;

/// Value of `--flavor` flag
final String? flavor;

/// Value of `--prefix` flag
final String prefixPath;

/// Creates an instance of [IconGeneratorContext]
IconGeneratorContext({
required this.config,
this.flavor,
Expand Down
16 changes: 16 additions & 0 deletions lib/constants.dart
@@ -1,7 +1,11 @@
import 'package:path/path.dart' as path;

/// Relative path to android resource folder
String androidResFolder(String? flavor) => "android/app/src/${flavor ?? 'main'}/res/";

/// Relative path to android colors.xml file
String androidColorsFile(String? flavor) => "android/app/src/${flavor ?? 'main'}/res/values/colors.xml";

const String androidManifestFile = 'android/app/src/main/AndroidManifest.xml';
const String androidGradleFile = 'android/app/build.gradle';
const String androidLocalPropertiesFile = 'android/local.properties';
Expand All @@ -17,13 +21,25 @@ const String iosConfigFile = 'ios/Runner.xcodeproj/project.pbxproj';
const String iosDefaultIconName = 'Icon-App';

// web
/// favicon.ico size
const int kFaviconSize = 16;

/// Relative web direcotry path
String webDirPath = path.join('web');

/// Relative web icons directory path
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
/// Relative favicon.png path
String webFaviconFilePath = path.join(webDirPath, 'favicon.png');

/// Relative index.html file path
String webIndexFilePath = path.join(webDirPath, 'index.html');

/// Relative pubspec.yaml path
String pubspecFilePath = path.join('pubspec.yaml');

const String errorMissingImagePath =
Expand Down
4 changes: 4 additions & 0 deletions lib/custom_exceptions.dart
Expand Up @@ -40,10 +40,14 @@ class NoDecoderForImageFormatException implements Exception {
}
}

/// A exception to throw when given [fileName] is not found
class FileNotFoundException implements Exception {
/// Creates a instance of [FileNotFoundException].
const FileNotFoundException(this.fileName);

/// Name of the file
final String fileName;

@override
String toString() {
return generateError(this, '$fileName file not found');
Expand Down
10 changes: 10 additions & 0 deletions lib/flutter_launcher_icons_config.dart
Expand Up @@ -10,6 +10,7 @@ import 'utils.dart' as utils;

part 'flutter_launcher_icons_config.g.dart';

/// A Config parsed from flutter_launcher_config.yaml
@JsonSerializable(
anyMap: true,
checked: true,
Expand Down Expand Up @@ -45,6 +46,7 @@ class FlutterLauncherIconsConfig {
@JsonKey(name: 'web')
final WebConfig? webConfig;

/// Creates an instance of [FlutterLauncherIconsConfig]
const FlutterLauncherIconsConfig({
this.imagePath,
this.android = false,
Expand All @@ -56,6 +58,7 @@ class FlutterLauncherIconsConfig {
this.webConfig,
});

/// Creates [FlutterLauncherIconsConfig] icons from [json]
factory FlutterLauncherIconsConfig.fromJson(Map json) => _$FlutterLauncherIconsConfigFromJson(json);

/// Loads flutter launcher icons configs from given [filePath]
Expand Down Expand Up @@ -108,21 +111,25 @@ class FlutterLauncherIconsConfig {
}
}

/// Creates [FlutterLauncherIconsConfig] for given [flavor] and [prefixPath]
static FlutterLauncherIconsConfig? loadConfigFromFlavor(String flavor, String prefixPath) {
return FlutterLauncherIconsConfig.loadConfigFromPath(utils.flavorConfigFile(flavor), prefixPath);
}

/// Converts config to [Map]
Map<String, dynamic> toJson() => _$FlutterLauncherIconsConfigToJson(this);

@override
String toString() => 'FlutterLauncherIconsConfig: ${toJson()}';
}

/// Parse `web` config from `flutter_launcher_icons.yaml`
@JsonSerializable(
anyMap: true,
checked: true,
)
class WebConfig {
/// Specifies weather to generate icons for web
final bool generate;

/// Image path for web
Expand All @@ -137,15 +144,18 @@ class WebConfig {
@JsonKey(name: 'theme_color')
final String? themeColor;

/// Creates an instance of [WebConfig]
const WebConfig({
this.generate = false,
this.imagePath,
this.backgroundColor,
this.themeColor,
});

/// Creates [WebConfig] from [json]
factory WebConfig.fromJson(Map json) => _$WebConfigFromJson(json);

/// Creates [Map] from [WebConfig]
Map<String, dynamic> toJson() => _$WebConfigToJson(this);

@override
Expand Down
3 changes: 2 additions & 1 deletion lib/logger.dart
Expand Up @@ -23,9 +23,10 @@ class FLILogger {
/// Logs error messages
void error(Object? message) => _logger.stderr('⚠️' + message.toString());

/// prings to console if [isVerbose] is true
/// Prints to console if [isVerbose] is true
void verbose(Object? message) => _logger.trace(message.toString());

/// Prints to console
void info(Object? message) => _logger.stdout(message.toString());

/// Shows progress in console
Expand Down
5 changes: 5 additions & 0 deletions lib/web/web_icon_generator.dart
Expand Up @@ -9,6 +9,8 @@ import '../custom_exceptions.dart';
import '../utils.dart' as utils;
import 'web_template.dart';

// This is not yet implemented
// ignore: public_member_api_docs
final metaTagsTemplate = (
String appleMobileWebAppTitle,
String appleMobileWebAppStatusBarStyle, {
Expand Down Expand Up @@ -39,6 +41,9 @@ class WebIconGenerator extends IconGenerator {
WebIconTemplate(size: 512, maskable: true),
];

/// Creates an instance of [WebIconGenerator].
///
///
WebIconGenerator(IconGeneratorContext context) : super(context, 'Web');

@override
Expand Down
13 changes: 10 additions & 3 deletions lib/web/web_template.dart
@@ -1,12 +1,19 @@
/// A Icon Template for Web
class WebIconTemplate {
/// Size of the web icon
final int size;

/// Support for maskable icon
///
/// Refer to https://web.dev/maskable-icon/
final bool maskable;

/// Creates an instance of [WebIconTemplate].
const WebIconTemplate({
required this.size,
this.maskable = false,
});

final int size;
final bool maskable;

/// Icon file name
String get iconFile => 'Icon${maskable ? '-maskable' : ''}-$size.png';

Expand Down

0 comments on commit af10715

Please sign in to comment.