[flutter_tools] Allow flutter build aar to know the null safety mode ahead of time (#80000)

This commit is contained in:
Jonah Williams
2021-04-08 15:22:55 -07:00
committed by GitHub
parent a3e66b3967
commit ac770423ec
3 changed files with 15 additions and 7 deletions

View File

@@ -841,7 +841,7 @@ abstract class FlutterCommand extends Command<void> {
///
/// Throws a [ToolExit] if the current set of options is not compatible with
/// each other.
Future<BuildInfo> getBuildInfo({ BuildMode forcedBuildMode }) async {
Future<BuildInfo> getBuildInfo({ BuildMode forcedBuildMode, File forcedTargetFile }) async {
final bool trackWidgetCreation = argParser.options.containsKey('track-widget-creation') &&
boolArg('track-widget-creation');
@@ -891,8 +891,8 @@ abstract class FlutterCommand extends Command<void> {
// passing a flag. Examine the entrypoint file to determine if it
// is opted in or out.
final bool wasNullSafetyFlagParsed = argResults.wasParsed(FlutterOptions.kNullSafety);
if (!wasNullSafetyFlagParsed && argParser.options.containsKey('target')) {
final File entrypointFile = globals.fs.file(targetFile);
if (!wasNullSafetyFlagParsed && (argParser.options.containsKey('target') || forcedTargetFile != null)) {
final File entrypointFile = forcedTargetFile ?? globals.fs.file(targetFile);
final LanguageVersion languageVersion = determineLanguageVersion(
entrypointFile,
packageConfig.packageOf(entrypointFile.absolute.uri),