You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[ffigen] Generate a non-throwing fromValueOrNull on Dart enums #3712
staticATEntryPointfromValue(int value) =>fromValueOrNull(value) ??
(throwArgumentError('Unknown value for ATEntryPoint: $value'));
That keeps the generated output about the same size, since the switch appears only once.
Considerations
Naming:fromValueOrNull follows int.tryParse / firstOrNull style; tryFromValue would work too.
Opt-in vs. default: the method is small and has no effect unless called, so generating it always seems reasonable. If output size is a concern, it could sit behind an option.
Enums with duplicate values: these should behave the same as fromValue does today (it returns the canonical member).
Compatibility: the change only adds a method; existing fromValue behaviour stays the same.
Activity
liamappelbe commentedon Sep 30, 2026
Sounds good. I don't think it needs to be opt-in. It can be always enabled.
vikramsingh920 commentedon Oct 4, 2026
hii @jakobkordez and @liamappelbe
if it is still available, I'd like to work on this.
jakobkordez commentedon Oct 5, 2026
Sorry, I had it already completed but not committed and opened yet.