Skip to content

Commit

Permalink
feat(configs): added new configs to FlutterLauncherIconsConfig
Browse files Browse the repository at this point in the history
added `min_sdk_android` and `remove_alpha_ios` to `FlutterLauncherIconsConfig`
  • Loading branch information
RatakondalaArun committed Aug 1, 2022
1 parent 7e3b5a4 commit 0f3ad18
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/constants.dart
Expand Up @@ -13,6 +13,9 @@ const String androidLocalPropertiesFile = 'android/local.properties';
/// Relative path to flutter.gradle from flutter sdk path
const String androidFlutterGardlePath = 'packages/flutter_tools/gradle/flutter.gradle';

/// Default min_sdk value for android
/// https://github.com/flutter/flutter/blob/master/packages/flutter_tools/gradle/flutter.gradle#L35-L37
const int androidDefaultAndroidMinSDK = 21;
const String androidFileName = 'ic_launcher.png';
const String androidAdaptiveForegroundFileName = 'ic_launcher_foreground.png';
const String androidAdaptiveBackgroundFileName = 'ic_launcher_background.png';
Expand Down
10 changes: 10 additions & 0 deletions lib/flutter_launcher_icons_config.dart
Expand Up @@ -42,6 +42,14 @@ class FlutterLauncherIconsConfig {
@JsonKey(name: 'adaptive_icon_background')
final String? adaptiveIconBackground;

/// Android min_sdk_android
@JsonKey(name: 'min_sdk_android', defaultValue: constants.androidDefaultAndroidMinSDK)
final int minSdkAndroid;

/// IOS remove_alpha_ios
@JsonKey(name: 'remove_alpha_ios', defaultValue: true)
final bool removeAlphaIOS;

/// Web platform config
@JsonKey(name: 'web')
final WebConfig? webConfig;
Expand All @@ -59,6 +67,8 @@ class FlutterLauncherIconsConfig {
this.imagePathIOS,
this.adaptiveIconForeground,
this.adaptiveIconBackground,
this.minSdkAndroid = constants.androidDefaultAndroidMinSDK,
this.removeAlphaIOS = true,
this.webConfig,
this.windowsConfig,
});
Expand Down
8 changes: 8 additions & 0 deletions lib/flutter_launcher_icons_config.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions test/abs/icon_generator_test.mocks.dart
Expand Up @@ -29,6 +29,14 @@ class MockFlutterLauncherIconsConfig extends _i1.Mock
_i1.throwOnMissingStub(this);
}

@override
int get minSdkAndroid =>
(super.noSuchMethod(Invocation.getter(#minSdkAndroid), returnValue: 0)
as int);
@override
bool get removeAlphaIOS => (super
.noSuchMethod(Invocation.getter(#removeAlphaIOS), returnValue: false)
as bool);
@override
Map<String, dynamic> toJson() =>
(super.noSuchMethod(Invocation.method(#toJson, []),
Expand Down
4 changes: 4 additions & 0 deletions test/flutter_launcher_icons_config_test.dart
Expand Up @@ -28,9 +28,11 @@ void main() {
expect(configs.imagePathAndroid, isNotNull);
expect(configs.adaptiveIconBackground, isNotNull);
expect(configs.adaptiveIconForeground, isNotNull);
expect(configs.minSdkAndroid, equals(21));
// ios configs
expect(configs.ios, isTrue);
expect(configs.imagePathIOS, isNotNull);
expect(configs.removeAlphaIOS, isFalse);
// web configs
expect(configs.webConfig, isNotNull);
expect(configs.webConfig!.generate, isTrue);
Expand Down Expand Up @@ -91,9 +93,11 @@ void main() {
expect(configs.imagePathAndroid, isNotNull);
expect(configs.adaptiveIconBackground, isNotNull);
expect(configs.adaptiveIconForeground, isNotNull);
expect(configs.minSdkAndroid, equals(21));
// ios configs
expect(configs.ios, isTrue);
expect(configs.imagePathIOS, isNotNull);
expect(configs.removeAlphaIOS, isFalse);
// web configs
expect(configs.webConfig, isNotNull);
expect(configs.webConfig!.generate, isTrue);
Expand Down
4 changes: 4 additions & 0 deletions test/templates.dart
Expand Up @@ -7,6 +7,8 @@ flutter_icons:
image_path_ios: "assets/images/icon-1024x1024.png"
adaptive_icon_background: "assets/images/christmas-background.png"
adaptive_icon_foreground: "assets/images/icon-foreground-432x432.png"
min_sdk_android: 21
remove_alpha_ios: false
web:
generate: true
image_path: "app_icon.png" # filepath
Expand Down Expand Up @@ -123,6 +125,8 @@ flutter_icons:
image_path_ios: "assets/images/icon-1024x1024.png"
adaptive_icon_background: "assets/images/christmas-background.png"
adaptive_icon_foreground: "assets/images/icon-foreground-432x432.png"
min_sdk_android: 21
remove_alpha_ios: false
web:
generate: true
image_path: "app_icon.png" # filepath
Expand Down
8 changes: 8 additions & 0 deletions test/windows/windows_icon_generator_test.mocks.dart
Expand Up @@ -31,6 +31,14 @@ class MockFlutterLauncherIconsConfig extends _i1.Mock
_i1.throwOnMissingStub(this);
}

@override
int get minSdkAndroid =>
(super.noSuchMethod(Invocation.getter(#minSdkAndroid), returnValue: 0)
as int);
@override
bool get removeAlphaIOS => (super
.noSuchMethod(Invocation.getter(#removeAlphaIOS), returnValue: false)
as bool);
@override
Map<String, dynamic> toJson() =>
(super.noSuchMethod(Invocation.method(#toJson, []),
Expand Down

0 comments on commit 0f3ad18

Please sign in to comment.