Skip to content

ImageCompressionFlutter.dummyCallNativeCode shouldn't be able to return null #13

@zmuranaka

Description

@zmuranaka

@protected
Future dummyCallNativeCode(
String method,
Map<String, dynamic> data,
Future<ic.ImageFile> Function() callback,
) async {
try {
// Invoke will work only on Web, otherwise it will execute callback
final result = await _channel.invokeMethod(method, data);
if (result is Map) {
return ImageFileExtension.decode(result);
}
return null;
} on MissingPluginException catch (_) {
return await callback();
}
}

This method should not return null. It currently returns null if result is not a Map, but none of the other places that use this method expect null and will unexpectedly throw if they receive null.

Here is a list of all the places that call dummyCallNativeCode but do not handle receiving null:

return await dummyCallNativeCode(

return await dummyCallNativeCode(

return await dummyCallNativeCode(

return await dummyCallNativeCode(

return await dummyCallNativeCode(

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions