forked from firka/flutter
[flutter_tools] toolexit when using plugins with preview device (#136936)
Part of https://github.com/flutter/flutter/issues/130277 Without this, if a user runs an app that has plugins that call method channels with the `preview` device, the app will build successfully, however, they will get a runtime error when their dart code tries to call the method channel that does not exist in the native build (which was pre-built and thus does not include the plugin code). This change adds a validation when injecting plugins that will tool exit if the device-id is `preview` and their project contains plugins with method channels.
This commit is contained in:
committed by
GitHub
parent
5ebca79f76
commit
d550ba54eb
@@ -27,6 +27,7 @@ import '../dart/pub.dart';
|
||||
import '../device.dart';
|
||||
import '../features.dart';
|
||||
import '../globals.dart' as globals;
|
||||
import '../preview_device.dart';
|
||||
import '../project.dart';
|
||||
import '../reporting/reporting.dart';
|
||||
import '../web/compile.dart';
|
||||
@@ -1694,7 +1695,14 @@ Run 'flutter -h' (or 'flutter <command> -h') for available flutter commands and
|
||||
project: project,
|
||||
checkUpToDate: cachePubGet,
|
||||
);
|
||||
await project.regeneratePlatformSpecificTooling();
|
||||
|
||||
// null implicitly means all plugins are allowed
|
||||
List<String>? allowedPlugins;
|
||||
if (stringArg(FlutterGlobalOptions.kDeviceIdOption, global: true) == 'preview') {
|
||||
// The preview device does not currently support any plugins.
|
||||
allowedPlugins = PreviewDevice.supportedPubPlugins;
|
||||
}
|
||||
await project.regeneratePlatformSpecificTooling(allowedPlugins: allowedPlugins);
|
||||
if (reportNullSafety) {
|
||||
await _sendNullSafetyAnalyticsEvents(project);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user