Skip to content
This repository was archived by the owner on Mar 18, 2021. It is now read-only.
This repository was archived by the owner on Mar 18, 2021. It is now read-only.

@Bind.query('--') to Enum gives "No static parse method error" while static parse method is defined in Extension on that Enum. #861

Closed
@akasher

Description

@akasher
enum Roles {
  owner,
  admin,
  user,
}

extension rolesParser on Roles {
  static Roles parse(String value) {
    final Roles role = tryParse(value);
    if (role != null)
      return role;
  }
  static Roles tryParse(String input) {
    final String value = input.trim();
    return Roles.values.firstWhere((element) => element.toString().split('.')[1].toUpperCase() == value.toUpperCase());
  }
}

Bad state: Bad state: Invalid binding 'role' on 'UsersController.getUsers': Parameter type does not implement static parse method.
**** Stacktrace


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions