This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
[url_launcher] Fixed call to onPlatformViewCreated after dispose #5431
[url_launcher] Fixed call to onPlatformViewCreated after dispose #5431
Changes from all commits
8fb082e
a640546
3b09ff5
0354b1d
c49ce9b
00f0f2a
7b5e35a
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this disposed check be performed before actually asking the framework to create a platform_view?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the whole point of this fix is to check after the await, sort of like you do when do
if (!mounted) return;
after awaits in stateful widget methods. Besides, I can't see how_isDisposed
can be true before the await.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kristoffer-zliide the lifecycle of Flutter Widgets and platform views is somewhat separate. In this code, you're adding elements to the DOM (code) and then checking if the Widget has been disposed to then not call onPlatformViewCreated.
I don't think you need to modify the DOM at all, or call "create" on a "platform_view" if the Widget that is being initialized has been previously marked as disposed. That's why I asked you to move the
isDisposed
check above theinvokeMethod
, to exit as early as possible.In fact, if
onPlatformViewCreated
could be called multiple times earlier, this should be complaining aboutviewId
being already created. (Is thereportError
swallowing the exception on the web? Looking.)(Note: this LinkViewController was originally modeled to look like the
class _HtmlElementViewController
, here, so everything usedinitialized
instead ofdisposed
)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I appreciate the desire to skip anything that would need to be awaited, but I don't quite follow anything else you're writing. With the refactoring done in this PR, I don't think I need to read more than 15 lines of code in the Link.dart file to see that the check wouldn't do anything before the await, since
_asyncInitialize
is only called on newly constructedLinkViewController
s which have_isDisposed
set to false. Moving the check up also implies not doing it after, which was the whole point of the PR. But maybe I missed something in the refactoring?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just trying to understand what's flutter doing here, because I don't think we should be getting an "init" on something that has been already "disposed".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The framework seems to be disposing of the link while the
await invokeMethod 'create'
is executing, so when it's time to callonPlatformViewCreated
,viewId
is already disposed.Something like: