convertHeicToJpegBytes method
Implementation
@override
Future<Uint8List> convertHeicToJpegBytes(Uint8List bytes) async {
try {
final blob = html.Blob([bytes]);
final isHeic =
bytes.length > 4 &&
(bytes[0] == 0x66 &&
bytes[1] == 0x74 &&
bytes[2] == 0x79 &&
(bytes[3] == 0x70 || bytes[3] == 0x70));
if (!isHeic) {
return bytes;
}
final convertedBlob = await _convertHeicBlob(blob);
final reader = html.FileReader();
reader.readAsArrayBuffer(convertedBlob);
await reader.onLoad.first;
final result = reader.result as List<int>;
return Uint8List.fromList(result);
} catch (e) {
print('[FlutterImageConversion] Web bytes conversion failed: $e');
return bytes;
}
}