r/flutterhelp • • Mar 26 '24

RESOLVED Why does flutter run differently in debug/release?

Who thought this was a good idea? I just spent hours getting the layout of my app working correctly locally. I pushed it to my server thinking it was finally working and... blank screen and tons of errors.

Why would they allow invalid code to work when run in debug mode? I can't understand that decision. And the errors in release mode are absurdly opaque and provide no useful information. How do you guys deal with this?

0 Upvotes

20 comments sorted by

View all comments

2

u/SwampThrowawayPgy69 Mar 26 '24

What happens when you run the app in release mode on your dev machine?

Are you definitely not getting any errors printed to console when in dev mode? When running in dev mode with debugger no flutter exceptions thrown?

I’ve seen an app “running” in dev mode but throwing plenty exceptions all over the place, that same app didn’t “run” when compiled in release mode. But then it was never correct in the first place. If you’ve just been working on layout I’d check that first.

Release mode code is minified on web and mobile which is the correct thing to do for a production client app. If it’s just a server but not really a production environment you can disable the minification and you will preserve your class and variable names. To understand debug messages from minified code you need to ask the compiler to output the source-maps (web) or debug symbols (android / iOS) and store them. Sentry has been good for me for production error catching and inspecting.