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

2

u/MuhammedOzdogan Mar 26 '24

Could you please elaborate what kind of invalid code runs on debug mode?

1

u/[deleted] Mar 26 '24

I had a scaffold with an expanded as the main child, then a listview inside of that. It ran fine in debug mode, but in release it would not.

I has to make the first child of scaffold a column instead, and have my expanded further down the tree.

2

u/SwampThrowawayPgy69 Mar 26 '24

Expanded can only be a child of flex, column or row widget.

2

u/[deleted] Mar 26 '24

I get that now. Why would they let it work in debug mode though? What's the point of debug if it let's bugs seem to work?

3

u/Ivan_Gorchakov Mar 26 '24

You supposed to pay attention on debug console while running in debug mode (not closing it) 😉

1

u/[deleted] Mar 26 '24

Sure, but shouldn't something that fails to run in release also fail in debug? I get all kinds of random warnings that don't affect my app. For example, copying thr documentation exactly on how to set up autocomplete on username and passwords fields causes a bunch of toString() being called on null objects. Autocomplete still works on release and debug, even though I have over 100 lines of errors every time I click thr autofill pop-up.

I just don't like flutter.

3

u/Ivan_Gorchakov Mar 26 '24

It is better from the beginning of a project to try to resolve all stuff, that makes debug console "bip-bop-bip-bop-bop", because sooner or later you will find yourself searching one little error among tons or others errors/warnings. But, if you don't like it - don't dev on it.

1

u/[deleted] Mar 26 '24

I don't have a choice on this project.

Again, I copied the documentation exactly and the debug console still screams at me.

2

u/SkinFickle1735 Mar 27 '24

Some runtime Flutter errors are not hard (also depending on the case ofc), can't be differentiated from hard errors. So it is up to the developer to pay attention to the console.

And that why Widger/UI testing exists too

2

u/Alternative_Guava_32 Mar 26 '24

I totally sympathise with this. You should expect the same result from a debug build as a release build. Give me more information to debug the issue in debug mode but don't give me a different result. Large projects often have a significant amount of information going into the consol.

1

u/[deleted] Mar 26 '24

Thank you!

1

u/RichCorinthian Mar 26 '24

Or can you provide some of these opaque error messages?

1

u/[deleted] Mar 26 '24

I don't have the error anymore and was in incognito when I googled it.

It was something about "minified" and <id>

1

u/s00prtr00pr Mar 26 '24

The problem is you unticked “uncaught exceptions” in vscode

1

u/[deleted] Mar 26 '24

Android studio

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.

2

u/Classic-Dependent517 Mar 26 '24

So you havent tested your app on release mode and real devices before publishing?

1

u/l3down Mar 26 '24

Is this flutter web? If so you need to copy the assets into your web folder.

1

u/[deleted] Mar 26 '24

It’s a great idea, in fact, native solutions work the same way, why would you need all the development resources in your builds that are target to the stores/server? It sounds that you are introducing layout bugs that tend to render in debug but in release the system prevents them from showing, check your console in the screens where this is happening, it will tell you which component is not being rendered properly

1

u/rio_sk Mar 27 '24

Posts a useless rant on some subreddit. Absurdly opaque error, doesn't even know what the error really was. That explains a lot about the programming experience.