-
Notifications
You must be signed in to change notification settings - Fork 27.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[url_launcher]Error: setState() called after dispose(): _PlatformViewLinkState#946fb(lifecycle state: defunct, not mounted) #102741
Comments
Hi @kristoffer-zliide, Thanks for filing the issue. Please share a minimal and complete reproducible code to better address the issue |
@maheshmnj: I updated the example in a pull request that may fix it. You need to scroll quite aggressively in that simple example to reproduce it 😄 |
The error I get when I scroll in that list:
|
Thanks for the code sample @kristoffer-zliide, Can you please clarify on which platform is this issue on ? Screen.Recording.2022-04-29.at.12.27.02.PM.mov
I tried to reproduce the issue on Android, either I was not aggressive enough xD or the bug does not exist on Android code sampleimport 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:url_launcher/link.dart';
void main() {
runApp(MyApp());
}
class _HorizontalScrollBehavior extends MaterialScrollBehavior {
@override
Set<PointerDeviceKind> get dragDevices => <PointerDeviceKind>{
PointerDeviceKind.touch,
PointerDeviceKind.stylus,
PointerDeviceKind.invertedStylus,
PointerDeviceKind.mouse,
};
}
/// App for testing
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) => MaterialApp(
home: Scaffold(
body: ConstrainedBox(
constraints: const BoxConstraints(maxHeight: 300),
child: const _List(),
),
),
);
}
class _List extends StatelessWidget {
const _List({
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) => ScrollConfiguration(
behavior: _HorizontalScrollBehavior(),
child: ListView.separated(
scrollDirection: Axis.horizontal,
itemCount: 500,
separatorBuilder: (_, __) => const SizedBox(height: 24, width: 24),
itemBuilder: (_, int index) => Link(
uri: Uri.parse('https://example.com/$index'),
builder: (_, __) => GestureDetector(
onTap: () {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('https://example.com/$index')));
},
child: Card(
child: Padding(
padding: const EdgeInsets.all(64),
child: Text('#$index', textAlign: TextAlign.center),
)),
),
),
),
);
}
flutter doctor -v (mac)
|
@maheshmnj: Try a desktop browser and scrolling with the mouse. |
@kristoffer-zliide Unfortunately that doesn't seem to make any difference , I am unable to reproduce the error on Windows Web / Desktop app 2022-04-29.20-01-53_Trim.mp42022-04-29.19-44-26_Trim.mp4flutter doctor -v (windows)
details> |
@maheshmnj: maybe a little more aggressive: 😃 Screen.Recording.mp4Or, are you running directly from the PR, because there the issue is fixed? |
I still can't reproduce @kristoffer-zliide..
I am running on you can switch to master channel by running
flutter doctor -v (windows)
|
The PR I believe fixes it, the one I linked to with the example. It's a fix to the plugin, so it's not from flutter master, and I'm also running stable 2.10.5. But if you're running on just the example Flutter code, I think you should be able to repro it. |
@kristoffer-zliide I am trying this code sample , Can you please confirm if the issue reproduces with that sample? Also looking at your logs the error doesn't seem related to URL launcher But looks similar to #91814 |
@maheshmnj: really sorry, I didn't see the code in your reply because it was collapsed! That code should repro it with url_launcher 6.1.0. Both in the error I posted and in the repro video, you can see |
@maheshmnj : maybe try this and scroll fast downward with the mouse wheel:
|
Thanks for the code sample @kristoffer-zliide, I was able to reproduce the issue on stable and the master channel. On Scrolling a bit faster the exception is thrown. A reproducible code sample can be found here #102741 (comment) 2022-05-04.12-03-06_Trim.mp4The logs don't seem to point at the issue in the URL launcher plugin, so labeling it as a framework issue. logs
flutter doctor -v (windows)
|
@maheshmnj: sorry, what? I just highlighted two crucial parts of the log that are from url_launcher. Also, in the bug report, I link directly to the place in the code where the bug is: you cannot call |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
onPlatformViewCreated calls setState(), so it probably shouldn't be called indiscriminately after an async operation. Or, maybe onPlatformViewCreated shouldn't call setState without checking mounted state.
Easily reproducible by making a large list of widgets with Links and scroll through it.
The text was updated successfully, but these errors were encountered: