overwriteExistingIcons function
Future<void>
overwriteExistingIcons(
- OhosIconTemplate template,
- Image image,
- String? flavor, {
- List<
String> ? targetPaths,
Overwrites existing OHOS icons with the provided template and image
Implementation
Future<void> overwriteExistingIcons(
OhosIconTemplate template,
Image image,
String? flavor, {
List<String>? targetPaths,
}) async {
final Image newFile = utils.createResizedImage(template.size, image);
const String ohosProjectPath = 'ohos';
final List<String> defaultTargetPaths = <String>[
path.join(
ohosProjectPath,
'AppScope',
'resources',
'base',
'media',
template.fileName,
),
path.join(
ohosProjectPath,
'entry',
'src',
'main',
'resources',
'base',
'media',
template.fileName,
),
];
for (final targetPath in targetPaths ?? defaultTargetPaths) {
final pngFile = await File(targetPath).create(recursive: true);
await pngFile.writeAsBytes(encodePng(newFile));
}
}