Skip to content

[pigeon] Add support for collections of enums #133728

Description

@tarrinneal

As of flutter/packages#4580 pigeon supports enums as primitives across all platforms.

It still does not support collections of enums though.

List<Enum> is a fairly common type even in our own packages (ie. local_auth_ios), as such should be supported by pigeon.

Map<Enum> would is also needed.

Activity

  1. added
    packageflutter/packages repository. See also p: labels.
    p: pigeonrelated to pigeon messaging codegen tool
    on Aug 31, 2023
  2. added
    P2Important issues not at the top of the work list
    on Sep 7, 2023
  3. mohachouch commented on Feb 8, 2024

    @mohachouch

    Hello,

    Any news for this issue

  4. Marchuck commented on Feb 27, 2024

    @Marchuck

    I guess it's still not working.
    However, I figured out the following workaround by wrapping enum to the class, so it's a bit better type-safety than
    List<int?> (collection of ordinals) or List<String?> (collection of enum names):

    let's say we have following enum:

    enum Pet{CAT, DOG, FISH; }

    instead of

    @FlutterApi()
    abstract class PetsApi {
        List<Pet?> getPets();
    }
    

    do the following:

    class PetResponse{
        Pet? pet; //Pet.CAT
        String? key; //"cat"
    }

    The flutter api would look the following(you can map/filter nulls on native side)

    @FlutterApi()
    abstract class PetsApi {
        List<PetResponse?> getPets();
    }
  5. github-actions commented on Sep 13, 2024

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  6. locked as resolved and limited conversation to collaborators on Sep 13, 2024
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

    P2Important issues not at the top of the work listc: 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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions