Skip to content

_getCustomMapping throws exception for non-custom values #35

@klivin

Description

@klivin

Is it intentional to throw an exception for every enum that does not provide a custom value?
_getCustomMapping now throws "has no instance getter 'value'" exception here:

  static String? _getCustomMapping(dynamic enumItem) {
    try {
      // Access the value property if it exists
      final value = (enumItem as dynamic).value as String?;
      return value;
    } catch (_) {
      return null;
    }
  }

This has slowed my app down so much while debugging Throwing an exception for every enum without custom mapping is a much more expensive operation than doing some other dynamic checking that does throw exceptions. I recently upgraded my flutter to new stable version and updated a bunch of pubs including this one. Now my app crawls through loading json files that have enums...It's unusable as is, so I'll have to fork or choose a diff enum parser method.

Also it makes debugging impossible with breakpoints on All Exceptions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions