rknell / flutterEnumsToString

Better conversion of ENUMs to string for Flutter / Dart
Other
85 stars 23 forks source link

Package is broken on Flutter/Dart Web release mode builds. #23

Closed rydmike closed 3 years ago

rydmike commented 3 years ago

Just a heads up, but some fairly recent changes in Dart+Flutter SDK regarding how Flutter uses dart2js to minify JS code in web release mode builds, caused this package to break, but only for WEB release mode, it works fine for Web profile or debug mode builds and for all Arm and x86 target builds.

If Google Flutter+Dart team will actually fix the breaking change remains open for now. You can read more here:

https://github.com/flutter/flutter/issues/66236

It might be that the type of runtime type equality that you do in this package in the _isEnumItem check might not be supported on Web going forward, but let's see what the reply to the issue is.

rknell commented 3 years ago

Thanks for the heads up. I have put a notice on the readme

yjbanov commented 3 years ago

Due to much tighter code size constraints the dart2js compiler minifies code very aggressively, including enums. Perhaps there's a codegen-based solution to this? A build step could scan the code (perhaps looking for annotations of some sort) and extract the full names of enums and turning them into String constants. Compilers will not try to minify those.

rknell commented 3 years ago

This is fixed in 1.0.13, please upgrade to that ASAP.

The conversation continued over here for any more background info: https://github.com/rknell/flutterEnumsToString/pull/19

And for a good discussion about some type checking pitfalls, check out the discussion from above: https://github.com/flutter/flutter/issues/66236