Repository navigation
Regenerate Dart plugin registrant after a hot restart #76219
Copy link
Copy link
Closed
Labels
P1High-priority issues at the top of the work listHigh-priority issues at the top of the work listtoolAffects the "flutter" command-line tool. See also t: labels.Affects the "flutter" command-line tool. See also t: labels.
Milestone
Description
The Dart plugin registrant is generated once the app is initially compiled.
There's a case where a user may start a flutter run session, then change the pubspec.yaml in the middle, and then hot restart the app.
With the changes from #74469, these steps will yield into an error.
In the case the plugins were removed from pubpsec.yaml:
Error: Could not resolve the package 'url_launcher_linux' in 'package:url_launcher_linux/url_launcher_linux.dart'.
Error: Could not resolve the package 'url_launcher_macos' in 'package:url_launcher_macos/url_launcher_macos.dart'.
.dart_tool/flutter_build/generated_main.dart:9:8: Error: Not found: 'package:url_launcher_linux/url_launcher_linux.dart'
import 'package:url_launcher_linux/url_launcher_linux.dart';
^
.dart_tool/flutter_build/generated_main.dart:10:8: Error: Not found: 'package:url_launcher_macos/url_launcher_macos.dart'
import 'package:url_launcher_macos/url_launcher_macos.dart';
^
.dart_tool/flutter_build/generated_main.dart:15:7: Error: Getter not found: 'UrlLauncherPlugin'.
UrlLauncherPlugin.registerWith();
^^^^^^^^^^^^^^^^^
.dart_tool/flutter_build/generated_main.dart:17:7: Error: Getter not found: 'UrlLauncherPlugin'.
UrlLauncherPlugin.registerWith();
^^^^^^^^^^^^^^^^^
Performing hot restart... ⣾Error: Could not resolve the package 'url_launcher_linux' in 'package:url_launcher_linux/url_launcher_linux.dart'.
Error: Could not resolve the package 'url_launcher_macos' in 'package:url_launcher_macos/url_launcher_macos.dart'.
.dart_tool/flutter_build/generated_main.dart:9:8: Error: Not found: 'package:url_launcher_linux/url_launcher_linux.dart'
import 'package:url_launcher_linux/url_launcher_linux.dart';
^
.dart_tool/flutter_build/generated_main.dart:10:8: Error: Not found: 'package:url_launcher_macos/url_launcher_macos.dart'
import 'package:url_launcher_macos/url_launcher_macos.dart';
^
.dart_tool/flutter_build/generated_main.dart:15:7: Error: Getter not found: 'UrlLauncherPlugin'.
UrlLauncherPlugin.registerWith();
^^^^^^^^^^^^^^^^^
.dart_tool/flutter_build/generated_main.dart:17:7: Error: Getter not found: 'UrlLauncherPlugin'.
UrlLauncherPlugin.registerWith();
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P1High-priority issues at the top of the work listHigh-priority issues at the top of the work listtoolAffects the "flutter" command-line tool. See also t: labels.Affects the "flutter" command-line tool. See also t: labels.
Activity
jonahwilliams commentedon Feb 17, 2021
Either hot reload or hot restart could require regeneration - but only if the pubspec.yaml has changed. See the localizations code for some examples of how to wire this up https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/resident_runner.dart#L912
zanderso commentedon Mar 5, 2021
@blasten The beta branch cut is coming up very soon. What is the status of this?
blasten commentedon Mar 6, 2021
@cyanglaz offered help. Thanks! I will be OOO starting next week.
From a very quick look, it would need to call this function from here (Hot restart) if the pubpsec.yaml has changed since last time it was invoked.
cyanglaz commentedon Mar 8, 2021
I'm confused about the expected result. Just want to confirm:
If I remove some deps (say url_launcher), and do a hot reload/restart, I should see the error in the main description of this issue, correct?
So what is the issue? Is the issue about error not showing?
jonahwilliams commentedon Mar 8, 2021
It should be possible to remove a plugin from the pubspec and hot reload or restart without a compilation error.
cyanglaz commentedon Mar 9, 2021
I just tried with removing url_launcher in the middle of an app session, and run a hot restart, it seems fine, no error is generated.
Screen.Recording.2021-03-08.at.4.07.10.PM.mov
jonahwilliams commentedon Mar 9, 2021
If you removed url_launcher from your pubspec yaml in an example app that was using url_launcher you should get a compilation error - did pub get run and remove url_launcher from the package_config.json? You would also need to remove the usage from the app itself.
cyanglaz commentedon Mar 9, 2021
I removed the url_launcher when the app is running, then hot restarted.
The hot start did not run
pub get, which leads to no error.jonahwilliams commentedon Mar 9, 2021
The tool doesn't run pub for you on hot restart/reload
cyanglaz commentedon Mar 9, 2021
talked to @blasten, I need to apply flutter-team-archive/plugins#3577 to reproduce the issue.
jonahwilliams commentedon May 4, 2021
Fixed via #79669
github-actions commentedon Aug 2, 2021
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
flutter doctor -vand a minimal reproduction of the issue.