Skip to content

[pigeon] let Java FlutterApis be invoked with null callbacks #58913

@xster

Description

@xster

I had IDL with

@FlutterApi()
abstract class FlutterBookApi {
  void displayBookDetails(Book book);
}

it created Java code

public interface Reply<T> {
  void reply(T reply);
}
public void displayBookDetails(Book argInput, Reply<Void> callback) {
  BasicMessageChannel<Object> channel =
      new BasicMessageChannel<Object>(binaryMessenger, "dev.flutter.pigeon.FlutterBookApi.displayBookDetails", new StandardMessageCodec());
  HashMap inputMap = argInput.toMap();
  channel.send(inputMap, new BasicMessageChannel.Reply<Object>() {
    public void reply(Object channelReply) {
      callback.reply(null);
    }
  });
}

but if I don't care about the result, I can't pass null to callback since it doesn't null check and can crash.

cc @gaaclarke

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectp: pigeonrelated to pigeon messaging codegen toolpackageflutter/packages repository. See also p: labels.team-ecosystemOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions