Skip to content

Commit 01f5885

Browse files
kevmoopull[bot]
authored andcommitted
flutter_tool: DRY up arg helpers, use new typed arg functions (flutter#151784)
1 parent 5af1727 commit 01f5885

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

packages/flutter_tools/lib/src/runner/flutter_command.dart

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1884,29 +1884,20 @@ Run 'flutter -h' (or 'flutter <command> -h') for available flutter commands and
18841884
/// If no flag named [name] was added to the [ArgParser], an [ArgumentError]
18851885
/// will be thrown.
18861886
bool boolArg(String name, {bool global = false}) {
1887-
if (global) {
1888-
return globalResults![name] as bool;
1889-
}
1890-
return argResults![name] as bool;
1887+
return (global ? globalResults : argResults)!.flag(name);
18911888
}
18921889

18931890
/// Gets the parsed command-line option named [name] as a `String`.
18941891
///
18951892
/// If no option named [name] was added to the [ArgParser], an [ArgumentError]
18961893
/// will be thrown.
18971894
String? stringArg(String name, {bool global = false}) {
1898-
if (global) {
1899-
return globalResults![name] as String?;
1900-
}
1901-
return argResults![name] as String?;
1895+
return (global ? globalResults : argResults)!.option(name);
19021896
}
19031897

19041898
/// Gets the parsed command-line option named [name] as `List<String>`.
19051899
List<String> stringsArg(String name, {bool global = false}) {
1906-
if (global) {
1907-
return globalResults![name] as List<String>;
1908-
}
1909-
return argResults![name] as List<String>;
1900+
return (global ? globalResults : argResults)!.multiOption(name);
19101901
}
19111902
}
19121903

0 commit comments

Comments
 (0)