Revert "[flutter_tools] Remove --no-sound-null-safety #3" (#123969)

Revert "[flutter_tools] Remove --no-sound-null-safety #3"
This commit is contained in:
Casey Hillers
2023-04-02 17:19:22 -07:00
committed by GitHub
parent 1edd4549ea
commit 6fe54f8811
9 changed files with 137 additions and 98 deletions

View File

@@ -822,13 +822,20 @@ abstract class FlutterCommand extends Command<void> {
void addNullSafetyModeOptions({ required bool hide }) {
argParser.addFlag(FlutterOptions.kNullSafety,
help: 'This flag is deprecated as only null-safe code is supported.',
help:
'Whether to override the inferred null safety mode. This allows null-safe '
'libraries to depend on un-migrated (non-null safe) libraries. By default, '
'Flutter mobile & desktop applications will attempt to run at the null safety '
'level of their entrypoint library (usually lib/main.dart). Flutter web '
'applications will default to sound null-safety, unless specifically configured.',
defaultsTo: true,
hide: true,
hide: hide,
);
argParser.addFlag(FlutterOptions.kNullAssertions,
help: 'This flag is deprecated as only null-safe code is supported.',
hide: true,
help:
'Perform additional null assertions on the boundaries of migrated and '
'un-migrated code. This setting is not currently supported on desktop '
'devices.'
);
}
@@ -1480,16 +1487,6 @@ abstract class FlutterCommand extends Command<void> {
/// rather than calling [runCommand] directly.
@mustCallSuper
Future<FlutterCommandResult> verifyThenRunCommand(String? commandPath) async {
if (argParser.options.containsKey(FlutterOptions.kNullSafety) &&
argResults![FlutterOptions.kNullSafety] == false &&
globals.nonNullSafeBuilds == NonNullSafeBuilds.notAllowed) {
throwToolExit('''
Could not find an option named "no-${FlutterOptions.kNullSafety}".
Run 'flutter -h' (or 'flutter <command> -h') for available flutter commands and options.
''');
}
globals.preRunValidator.validate();
if (refreshWirelessDevices) {
@@ -1757,12 +1754,3 @@ DevelopmentArtifact? artifactFromTargetPlatform(TargetPlatform targetPlatform) {
/// Returns true if s is either null, empty or is solely made of whitespace characters (as defined by String.trim).
bool _isBlank(String s) => s.trim().isEmpty;
/// Whether the tool should allow non-null safe builds.
///
/// The Dart SDK no longer supports non-null safe builds, so this value in the
/// tool's context should always be [NonNullSafeBuilds.notAllowed].
enum NonNullSafeBuilds {
allowed,
notAllowed,
}