Solvro / mobile-topwr

ToPWR mobile flutter application
https://solvro.pwr.edu.pl/portfolio/to-pwr/
GNU Affero General Public License v3.0
33 stars 1 forks source link

[Mobile - 30] Android: back button/gesture kills app #64

Closed simon-the-shark closed 4 months ago

simon-the-shark commented 5 months ago

It looks a bit like a problem with flutter or embedder or smth: https://github.com/flutter/flutter/issues/117061 But maybe someone can fix this with some config

simon-the-shark commented 5 months ago

If you use back button/gesture and the app closes (as it should), but the problem is that this also kills the app and when you reenter it, it loads from start (cold start)

mikolaj-jalocha commented 4 months ago

Tried all the solutions and workarounds described here, but none of them worked.

simon-the-shark commented 4 months ago

I guess we just wait for some update

simon-the-shark commented 4 months ago

@mikolaj-jalocha I've played around with navigation-bug branch and I believe I've managed to achieve the same result without the usage of WillPopScope. You should defienetly test it out, but it works for me. Nevertheless, very good work with the whole idea.

Hopefully we'll be able to remove it in the future once they fix this (https://github.com/flutter/flutter/issues/117061)

Also now you know how does MethodChannel work, you can check out pigeon package too. It's using code generation to communicate between platforms with some type safety - but I think the setup is not worth this case, as we only have very simple temporary usage and the setup for pigeon may be kinda deadly. But for bigger project with loads of inter-platform code, then it may be a life saver (especially when you write platform-specific flutter plugins)

mikolaj-jalocha commented 4 months ago

@simon-the-shark Excellent job! I especially like the way you organized logic needed to determine if pop's possible. Very elegant in my opinion :-) I tested in on Android 11, works perfectly fine. I think we can merge?

Before, I didn't know about pigeonpacakge. It's defenitelly very usefull and I'm sure we will need to use it sooner or later (eg. with platforms widget future? ), thanks for showing me that :-) I'm looking forward to put it into the practice. In our current case, I also agree, it's definitely overkill.

Btw, I thought we could post our solution at the bug's thread maybe it'd help someone?

simon-the-shark commented 4 months ago

Yeah, you can merge.

About sharing the solution, it's a great idea and I've thought about it too.

We can obviosly share link to our PR, since the repo is public now.

But ideally, it would be nice to paste there some minimal step-by-step reproducible solution.

Maybe we can play round with a fresh flutter project and prepare solution for simpler situation without nested navigator (unless the nested navigator is the problem here)

I'm looking forward to sharing the solution too, so I can prepare something later today, but don't want to take away the fun from you, so if you want and have a free moment you can prepare something and I'll just look into it.

mikolaj-jalocha commented 4 months ago

I should craft something max till tomorrow (and will do it with fun :)) ) but feel free if you have time to spare to prepare sth today and maybe I could be some help later.