Skip to content

ArgResults: Make easier for Dart2 users #39

@matanlurey

Description

@matanlurey

This is a runtime failure in Dart2:

void readListOfNames(ArgResults results) {
  // "List<dynamic> is not a List<String>"
  List<String> names = results['names'];
}

... but patterns like this are really common.

I'd like to see a series of helper methods to make it easier to get common types and collections out of ArgResults, even if all they do behind the scenes is a combination of as and collection casts. Ideas:

Primitives

  • bool readBool(String name)
  • double readDouble(String name)
  • int readInt(String name)
  • String readString(String name)

Collections

  • List<String> readStringList(String name)

Thoughts?

/cc @nex3 @natebosch

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions