removeBackground method
Future<CutoutResult>
removeBackground(
- String imagePath, {
- required CutoutOptions options,
override
Removes the background from an image at the given path.
Implementation
@override
Future<CutoutResult> removeBackground(
String imagePath, {
required CutoutOptions options,
}) async {
try {
final result = await methodChannel.invokeMethod<Object>(
'removeBackground',
{'imagePath': imagePath, 'options': options.toMap()},
);
return switch (result) {
String path => CutoutFileSuccess(path),
Uint8List bytes => CutoutBytesSuccess(bytes),
_ => const CutoutFailure(
CutoutErrorCode.processingFailed,
'No result returned from native code',
),
};
} on PlatformException catch (e) {
final code = _parseErrorCode(e.code);
return CutoutFailure(code, e.message ?? 'Unknown error');
}
}