Skip to content

[pigeon] Support typesafe EventChannels #66711

@ryanheise

Description

@ryanheise

Use case

It would be useful to have typesafe event channels in pigeon as these currently have to be created manually (and type safety has to be ensured manually).

Proposal

Automatically translate Stream getters to event channels:

@HostApi()
abstract class VideoPlayerApi {
  // The following getter represents the new feature:
  Stream<VideoEvent> get videoEvents;
  void dispose();
  void setLooping(LoopingMessage msg);
  void setVolume(VolumeMessage msg);
  void play();
  PositionMessage position();
  void seekTo(PositionMessage msg);
  void pause();
  void setMixWithOthers(MixWithOthersMessage msg);
}

The above example is based on #66710 where an instance of this API represents a single instance of a video player, and so the videoEvents stream would map to an event channel for a particular video player instance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterp: pigeonrelated to pigeon messaging codegen toolpackageflutter/packages repository. See also p: labels.team-ecosystemOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem team

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions