app icon change progress but i'm tired bye
This commit is contained in:
parent
1c014d90af
commit
f8246338d8
@ -1,48 +1,60 @@
|
|||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_dynamic_icon/flutter_dynamic_icon.dart';
|
import 'package:flutter_dynamic_icon_plus/flutter_dynamic_icon_plus.dart';
|
||||||
import 'package:android_dynamic_icon/android_dynamic_icon.dart';
|
|
||||||
|
|
||||||
class AppIconHelper {
|
class AppIconHelper {
|
||||||
static const _channel = MethodChannel('app_icon');
|
// static const _channel = MethodChannel('app_icon');
|
||||||
|
|
||||||
static Future<void> setAppIcon(String iconName) async {
|
static Future<void> setAppIcon(String iconName) async {
|
||||||
if (Platform.isIOS) {
|
|
||||||
// change icon on ios
|
|
||||||
try {
|
try {
|
||||||
if (await FlutterDynamicIcon.supportsAlternateIcons) {
|
if (await FlutterDynamicIconPlus.supportsAlternateIcons) {
|
||||||
await _channel.invokeMethod('changeIcon', iconName);
|
await FlutterDynamicIconPlus.setAlternateIconName("icon_new");
|
||||||
// await FlutterDynamicIcon.setApplicationIconBadgeNumber(0); we don't need this rn, but we will
|
|
||||||
await FlutterDynamicIcon.setAlternateIconName(iconName);
|
|
||||||
}
|
|
||||||
} on PlatformException catch (e) {
|
|
||||||
if (kDebugMode) {
|
if (kDebugMode) {
|
||||||
print('Failed to change app icon: ${e.message}');
|
print("successfully changed app icon");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} on PlatformException {
|
||||||
|
if (kDebugMode) {
|
||||||
|
print("failed to change icon");
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (kDebugMode) {
|
// ha nem megy hat nem megy
|
||||||
print('Ha nem megy, hat nem megy');
|
}
|
||||||
}
|
// if (Platform.isIOS) {
|
||||||
}
|
// // change icon on ios
|
||||||
} else if (Platform.isAndroid) {
|
// try {
|
||||||
// change icon on android
|
// if (await FlutterDynamicIcon.supportsAlternateIcons) {
|
||||||
// ignore: no_leading_underscores_for_local_identifiers
|
// await _channel.invokeMethod('changeIcon', iconName);
|
||||||
final _androidDynamicIconPlugin = AndroidDynamicIcon();
|
// // await FlutterDynamicIcon.setApplicationIconBadgeNumber(0); we don't need this rn, but we will
|
||||||
await _androidDynamicIconPlugin.changeIcon(
|
// await FlutterDynamicIcon.setAlternateIconName(iconName);
|
||||||
bundleId: 'hu.refilc.naplo',
|
// }
|
||||||
isNewIcon: iconName != 'refilc_default' ? true : false,
|
// } on PlatformException catch (e) {
|
||||||
iconName: iconName != 'refilc_default' ? iconName : '',
|
// if (kDebugMode) {
|
||||||
iconNames: [
|
// print('Failed to change app icon: ${e.message}');
|
||||||
'refilc_default',
|
// }
|
||||||
'refilc_overcomplicated',
|
// } catch (e) {
|
||||||
'refilc_concept',
|
// if (kDebugMode) {
|
||||||
'refilc_pride',
|
// print('Ha nem megy, hat nem megy');
|
||||||
],
|
// }
|
||||||
);
|
// }
|
||||||
} else {
|
// } else if (Platform.isAndroid) {
|
||||||
// ha nem megy hát nem megy
|
// // change icon on android
|
||||||
}
|
// // ignore: no_leading_underscores_for_local_identifiers
|
||||||
|
// final _androidDynamicIconPlugin = AndroidDynamicIcon();
|
||||||
|
// await _androidDynamicIconPlugin.changeIcon(
|
||||||
|
// bundleId: 'hu.refilc.naplo',
|
||||||
|
// isNewIcon: iconName != 'refilc_default' ? true : false,
|
||||||
|
// iconName: iconName != 'refilc_default' ? iconName : '',
|
||||||
|
// iconNames: [
|
||||||
|
// 'refilc_default',
|
||||||
|
// 'refilc_overcomplicated',
|
||||||
|
// 'refilc_concept',
|
||||||
|
// 'refilc_pride',
|
||||||
|
// ],
|
||||||
|
// );
|
||||||
|
// } else {
|
||||||
|
// // ha nem megy hát nem megy
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,7 @@ dependencies:
|
|||||||
i18n_extension: ^11.0.12
|
i18n_extension: ^11.0.12
|
||||||
http: ^1.2.0
|
http: ^1.2.0
|
||||||
fl_chart: ^0.45.1
|
fl_chart: ^0.45.1
|
||||||
|
flutter_dynamic_icon_plus: ^1.1.2
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_lints: ^3.0.1
|
flutter_lints: ^3.0.1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user