@@ -43,7 +43,7 @@ void createDefaultIcons(Map<String, dynamic> flutterLauncherIconsConfig, String?
43
43
isAndroidIconNameCorrectFormat (iconName);
44
44
final String iconPath = '$iconName .png' ;
45
45
for (AndroidIconTemplate template in androidIcons) {
46
- saveNewImages (template, image, iconPath, flavor);
46
+ _saveNewImages (template, image, iconPath, flavor);
47
47
}
48
48
overwriteAndroidManifestWithNewLauncherIcon (iconName, androidManifestFile);
49
49
} else {
@@ -82,7 +82,7 @@ void createAdaptiveIcons(Map<String, dynamic> flutterLauncherIconsConfig, String
82
82
83
83
// Create adaptive icon background
84
84
if (isAdaptiveIconConfigPngFile (backgroundConfig)) {
85
- createAdaptiveBackgrounds (flutterLauncherIconsConfig, backgroundConfig, flavor);
85
+ _createAdaptiveBackgrounds (flutterLauncherIconsConfig, backgroundConfig, flavor);
86
86
} else {
87
87
createAdaptiveIconMipmapXmlFile (flutterLauncherIconsConfig, flavor);
88
88
updateColorsXmlFile (backgroundConfig, flavor);
@@ -127,8 +127,11 @@ void createAdaptiveIconMipmapXmlFile(Map<String, dynamic> flutterLauncherIconsCo
127
127
}
128
128
129
129
/// creates adaptive background using png image
130
- void createAdaptiveBackgrounds (
131
- Map <String , dynamic > yamlConfig, String adaptiveIconBackgroundImagePath, String ? flavor) {
130
+ void _createAdaptiveBackgrounds (
131
+ Map <String , dynamic > yamlConfig,
132
+ String adaptiveIconBackgroundImagePath,
133
+ String ? flavor,
134
+ ) {
132
135
final String filePath = adaptiveIconBackgroundImagePath;
133
136
final Image ? image = decodeImageFile (filePath);
134
137
if (image == null ) {
@@ -138,7 +141,7 @@ void createAdaptiveBackgrounds(
138
141
// creates a png image (ic_adaptive_background.png) for the adaptive icon background in each of the locations
139
142
// it is required
140
143
for (AndroidIconTemplate androidIcon in adaptiveForegroundIcons) {
141
- saveNewImages (androidIcon, image, constants.androidAdaptiveBackgroundFileName, flavor);
144
+ _saveNewImages (androidIcon, image, constants.androidAdaptiveBackgroundFileName, flavor);
142
145
}
143
146
144
147
// Creates the xml file required for the adaptive launcher icon
@@ -225,7 +228,7 @@ void overwriteExistingIcons(
225
228
/// Saves new launcher icons to the project, keeping the old launcher icons.
226
229
/// Note: Do not change interpolation unless you end up with better results
227
230
/// https://github.com/fluttercommunity/flutter_launcher_icons/issues/101#issuecomment-495528733
228
- void saveNewImages (AndroidIconTemplate template, Image image, String iconFilePath, String ? flavor) {
231
+ void _saveNewImages (AndroidIconTemplate template, Image image, String iconFilePath, String ? flavor) {
229
232
final Image newFile = createResizedImage (template.size, image);
230
233
File (constants.androidResFolder (flavor) + template.directoryName + '/' + iconFilePath)
231
234
.create (recursive: true )
@@ -241,12 +244,12 @@ void saveNewImages(AndroidIconTemplate template, Image image, String iconFilePat
241
244
Future <void > overwriteAndroidManifestWithNewLauncherIcon (String iconName, File androidManifestFile) async {
242
245
// we do not use `file.readAsLinesSync()` here because that always gets rid of the last empty newline
243
246
final List <String > oldManifestLines = (await androidManifestFile.readAsString ()).split ('\n ' );
244
- final List <String > transformedLines = transformAndroidManifestWithNewLauncherIcon (oldManifestLines, iconName);
247
+ final List <String > transformedLines = _transformAndroidManifestWithNewLauncherIcon (oldManifestLines, iconName);
245
248
await androidManifestFile.writeAsString (transformedLines.join ('\n ' ));
246
249
}
247
250
248
251
/// Updates only the line containing android:icon with the specified iconName
249
- List <String > transformAndroidManifestWithNewLauncherIcon (List <String > oldManifestLines, String iconName) {
252
+ List <String > _transformAndroidManifestWithNewLauncherIcon (List <String > oldManifestLines, String iconName) {
250
253
return oldManifestLines.map ((String line) {
251
254
if (line.contains ('android:icon' )) {
252
255
// Using RegExp replace the value of android:icon to point to the new icon
@@ -274,13 +277,15 @@ int? minSdk() {
274
277
final androidLocalPropertiesFile = File (constants.androidLocalPropertiesFile);
275
278
276
279
// looks for minSdk value in build.gradle, flutter.gradle & local.properties.
277
- return getMinSdkFlutterGradle (androidLocalPropertiesFile) ??
278
- getMinSdkFromFile (androidGradleFile) ??
279
- getMinSdkFromFile (androidLocalPropertiesFile);
280
+ // this should always be order
281
+ // first check build.gradle, then local.properties, then flutter.gradle
282
+ return _getMinSdkFromFile (androidGradleFile) ??
283
+ _getMinSdkFromFile (androidLocalPropertiesFile) ??
284
+ _getMinSdkFlutterGradle (androidLocalPropertiesFile);
280
285
}
281
286
282
287
/// Retrieves the minSdk value from [File]
283
- int ? getMinSdkFromFile (File file) {
288
+ int ? _getMinSdkFromFile (File file) {
284
289
final List <String > lines = file.readAsLinesSync ();
285
290
for (String line in lines) {
286
291
if (line.contains ('minSdkVersion' )) {
@@ -297,9 +302,9 @@ int? getMinSdkFromFile(File file) {
297
302
return null ; // Didn't find minSdk, assume the worst
298
303
}
299
304
300
- /// A helper function to [getMinSdkFlutterGradle ]
305
+ /// A helper function to [_getMinSdkFlutterGradle ]
301
306
/// which retrives value of `flutter.sdk` from `local.properties` file
302
- String ? getFlutterSdkPathFromLocalProperties (File file) {
307
+ String ? _getFlutterSdkPathFromLocalProperties (File file) {
303
308
final List <String > lines = file.readAsLinesSync ();
304
309
for (String line in lines) {
305
310
if (! line.contains ('flutter.sdk=' )) {
@@ -318,8 +323,8 @@ String? getFlutterSdkPathFromLocalProperties(File file) {
318
323
}
319
324
320
325
/// Retrives value of `minSdkVersion` from `flutter.gradle`
321
- int ? getMinSdkFlutterGradle (File localPropertiesFile) {
322
- final flutterRoot = getFlutterSdkPathFromLocalProperties (localPropertiesFile);
326
+ int ? _getMinSdkFlutterGradle (File localPropertiesFile) {
327
+ final flutterRoot = _getFlutterSdkPathFromLocalProperties (localPropertiesFile);
323
328
if (flutterRoot == null ) {
324
329
return null ;
325
330
}
0 commit comments