normalizeImageForUpload function
Implementation
Future<String> normalizeImageForUpload(
String filePath, {
required bool isCamera,
}) async {
if (!isCamera || kIsWeb || defaultTargetPlatform != TargetPlatform.iOS) {
return filePath;
}
try {
final temporaryDirectory = await getTemporaryDirectory();
final targetPath =
'${temporaryDirectory.path}/nim_avatar_${DateTime.now().microsecondsSinceEpoch}.jpg';
final normalized = await FlutterImageCompress.compressAndGetFile(
filePath,
targetPath,
format: CompressFormat.jpeg,
quality: 90,
autoCorrectionAngle: true,
keepExif: false,
);
return normalized?.path ?? filePath;
} catch (_) {
return filePath;
}
}