Skip to content

Regenerate Dart plugin registrant after a hot restart #76219

@blasten

Description

@blasten

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();

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work listtoolAffects the "flutter" command-line tool. See also t: labels.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions