INNER CODE UNIT · Dart
registerWith
fluttercandies/flutter_image_compress · packages/flutter_image_compress_common/lib/flutter_image_compress_common.dart:41
static void registerWith() {
FlutterImageCompressPlatform.instance = FlutterImageCompressCommon();
}
/// Wrap [MethodChannel.invokeMethod] so native `result.error(...)` /
/// `replyError(...)` calls surface as [CompressError] on the Dart side
/// instead of leaking as [PlatformException] or (worse) a silent null
/// return type-cast failure. The native code carries a stable failure
/// code (see [CompressError.code]) and a human message.
Future<T?> _invoke<T>(String method, [dynamic args]) async {
try {
return await _channel.invokeMethod<T>(method, args);
} on PlatformException catch (e) {
throw CompressError(e.message ?? e.code, code: e.code);
}
}
@override