Skip to content

[tools] Consider adding getter methods to Config that cast values for better type-safety #128278

@andrewkolos

Description

@andrewkolos

Discovered while implementing #128264 in this comment.

Perhaps we could add methods similar to these ones from FlutterCommand:

bool boolArg(String name, {bool global = false}) {
if (global) {
return globalResults![name] as bool;
}
return argResults![name] as bool;
}
/// Gets the parsed command-line option named [name] as a `String`.
///
/// If no option named [name] was added to the [ArgParser], an [ArgumentError]
/// will be thrown.
String? stringArg(String name, {bool global = false}) {
if (global) {
return globalResults![name] as String?;
}
return argResults![name] as String?;
}
/// Gets the parsed command-line option named [name] as `List<String>`.
List<String> stringsArg(String name, {bool global = false}) {
if (global) {
return globalResults![name] as List<String>;
}
return argResults![name] as List<String>;
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: tech-debtTechnical debt, code quality, testing, etc.team-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.tool-still-validIssues that have been deemed still valid as part of the Flutter Tools issue cleanup initiative.triaged-toolTriaged by Flutter Tool team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions