diff --git a/README.md b/README.md index 9b54cb987d..b8b08e97cd 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,7 @@ Shown below is the full list of attributes which you can specify within your Flu be used to fill out the background of the adaptive icon. - `adaptive_icon_foreground`: The image asset which will be used for the icon foreground of the adaptive icon *Note: Adaptive Icons will only be generated when both adaptive_icon_background and adaptive_icon_foreground are specified. (the image_path is not automatically taken as foreground)* +- `adaptive_icon_foreground_inset`: This is used to add padding to the icon when applying an adaptive icon. The default value is `16`. - `adaptive_icon_monochrome`: The image asset which will be used for the icon foreground of the Android 13+ themed icon. For more information see [Android Adaptive Icons](https://developer.android.com/develop/ui/views/launch/icon_design_adaptive#user-theming) diff --git a/example/default_example/pubspec.yaml b/example/default_example/pubspec.yaml index b3aab90ccd..5e87c2c9f0 100644 --- a/example/default_example/pubspec.yaml +++ b/example/default_example/pubspec.yaml @@ -21,6 +21,7 @@ flutter_launcher_icons: ios: true # can specify file name here e.g. "My-Launcher-Icon" adaptive_icon_background: "assets/images/christmas-background.png" # only available for Android 8.0 devices and above adaptive_icon_foreground: "assets/images/icon-foreground-432x432.png" # only available for Android 8.0 devices and above + adaptive_icon_foreground_inset: 16 # only available for Android 8.0 devices and above adaptive_icon_monochrome: "assets/images/icon-monochrome-432x432.png" # only available for Android 13 devices and above min_sdk_android: 21 # android min sdk min:16, default 21 remove_alpha_ios: true diff --git a/lib/android.dart b/lib/android.dart index a9e8327b9a..30249890f4 100644 --- a/lib/android.dart +++ b/lib/android.dart @@ -171,13 +171,23 @@ void createMipmapXmlFile( ' \n'; } - xmlContent += - ' \n'; + xmlContent += ''' + + + +'''; } if (config.hasAndroidAdaptiveMonochromeConfig) { - xmlContent += - ' \n'; + xmlContent += ''' + + + +'''; } late File mipmapXmlFile; diff --git a/lib/config/config.dart b/lib/config/config.dart index df650dac98..9ac513c968 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -28,6 +28,7 @@ class Config { this.imagePathIOSDarkTransparent, this.imagePathIOSTintedGrayscale, this.adaptiveIconForeground, + this.adaptiveIconForegroundInset = 16, this.adaptiveIconBackground, this.adaptiveIconMonochrome, this.minSdkAndroid = constants.androidDefaultAndroidMinSDK, @@ -132,6 +133,10 @@ class Config { @JsonKey(name: 'adaptive_icon_foreground') final String? adaptiveIconForeground; + /// android adaptive_icon_foreground inset + @JsonKey(name: 'adaptive_icon_foreground_inset') + final int adaptiveIconForegroundInset; + /// android adaptive_icon_background image @JsonKey(name: 'adaptive_icon_background') final String? adaptiveIconBackground; diff --git a/lib/config/config.g.dart b/lib/config/config.g.dart index ed9100de04..5087f1846d 100644 --- a/lib/config/config.g.dart +++ b/lib/config/config.g.dart @@ -23,6 +23,8 @@ Config _$ConfigFromJson(Map json) => $checkedCreate( 'image_path_ios_tinted_grayscale', (v) => v as String?), adaptiveIconForeground: $checkedConvert('adaptive_icon_foreground', (v) => v as String?), + adaptiveIconForegroundInset: + $checkedConvert('adaptive_icon_foreground_inset', (v) => v as int? ?? 16), adaptiveIconBackground: $checkedConvert('adaptive_icon_background', (v) => v as String?), adaptiveIconMonochrome: @@ -54,6 +56,7 @@ Config _$ConfigFromJson(Map json) => $checkedCreate( 'imagePathIOSDarkTransparent': 'image_path_ios_dark_transparent', 'imagePathIOSTintedGrayscale': 'image_path_ios_tinted_grayscale', 'adaptiveIconForeground': 'adaptive_icon_foreground', + 'adaptiveIconForegroundInset': 'adaptive_icon_foreground_inset', 'adaptiveIconBackground': 'adaptive_icon_background', 'adaptiveIconMonochrome': 'adaptive_icon_monochrome', 'minSdkAndroid': 'min_sdk_android', @@ -75,6 +78,7 @@ Map _$ConfigToJson(Config instance) => { 'image_path_ios_dark_transparent': instance.imagePathIOSDarkTransparent, 'image_path_ios_tinted_grayscale': instance.imagePathIOSTintedGrayscale, 'adaptive_icon_foreground': instance.adaptiveIconForeground, + 'adaptive_icon_foreground_inset': instance.adaptiveIconForegroundInset, 'adaptive_icon_background': instance.adaptiveIconBackground, 'adaptive_icon_monochrome': instance.adaptiveIconMonochrome, 'min_sdk_android': instance.minSdkAndroid,