checkRotation method
Implementation
Future<int?>checkRotation(File beforeFile) async {
if (Platform.isAndroid){
var platform = MethodChannel('com.csi.sellon/checkRotation');
try {
// print("di panggil lagi");
final args = <String, dynamic>{
'path': beforeFile.path,
};
var result = await platform.invokeMethod('checkRotation',args);
if (result == "" || result == null) {
result = 0;
}
return result;
// print("result Apple delete ${resultname}");
// batteryLevel = 'Battery level at $result % .';
} on PlatformException catch (e) {
// batteryLevel = "Failed applename '${e.message}'.";
return 0;
}
}else{
RotationImage rotat = RotationImage.noChange;
int rotate = 0;
List<int> imageBytes = await beforeFile.readAsBytes();
Map<String, IfdTag> exifData = await readExifFromBytes(imageBytes);
await decodeImageFromList(beforeFile.readAsBytesSync()).then((decodedImage) async {
bool isHorizontalImage = decodedImage.width > decodedImage.height;
double standart = (decodedImage.width - decodedImage.height).toDouble();
double separuhwidth = decodedImage.width / 2 + 100;
if (isHorizontalImage && separuhwidth < standart){
if (exifData.length == 0){
rotate = 1;
}else{
rotate = 0;
}
}
return rotate;
});
return rotate;
}
}