Skip to content

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

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

Activity

  1. added
    packageflutter/packages repository. See also p: labels.
    on Jun 7, 2020
  2. matejdro commented on Sep 24, 2020

    @matejdro

    What would be even better is if instead of null, you add overload method that just omits the callback.

  3. matejdro commented on Oct 12, 2020

    @matejdro

    @gaaclarke I don't think this ticket is relevant to the flutter/packages#222

    This ticket is for the native APIs (such as Java APIs)

  4. gaaclarke commented on Oct 12, 2020

    @gaaclarke
    Member

    Sorry, keeping the languages straight has been a problem for me. Thanks for the heads up. I'll update the title.

  5. changed the title [-][pigeon] let FlutterApis be invoked with null callbacks[/-] [+][pigeon] let Java FlutterApis be invoked with null callbacks[/+] on Oct 12, 2020
  6. stuartmorgan-g commented on Oct 26, 2021

    @stuartmorgan-g
    Contributor

    Was this fixed by flutter/packages#214?

  7. gaaclarke commented on Oct 26, 2021

    @gaaclarke
    Member

    Was this fixed by flutter/packages#214?

    Nope, you still have to provide a callback.

  8. added
    P3Issues that are less important to the Flutter project
    on Nov 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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