Make connectToService return a Future that gets completed by the onServiceConnected callback. (Likely using a Completer.)
Not going into too much more detail because I see in the repository that all the code is completely different already, this comment is more to try to provide other passers-by with some tools to avoid the same structural issues. :)
Oh, my mistake, I was missing that that entire section isn't Flutter/Dart code at all! Found it further into the repository. Turns out nearly all of the post's code is Java!
The same premise still applies, but now it all makes more sense to me as well. :)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
A small suggestion for how you could avoid the tangle of keepResult:
Make onMethodCall an async function.
In onMethodCall's "connect" branch,
Make connectToService return a Future that gets completed by the onServiceConnected callback. (Likely using a
Completer
.)Not going into too much more detail because I see in the repository that all the code is completely different already, this comment is more to try to provide other passers-by with some tools to avoid the same structural issues. :)
Oh, my mistake, I was missing that that entire section isn't Flutter/Dart code at all! Found it further into the repository. Turns out nearly all of the post's code is Java!
The same premise still applies, but now it all makes more sense to me as well. :)