Skip to content

[flutter_tools] boolArg() should be non-nullable, and throw if the flag doesn't exist #105263

Closed

Activity

  1. added
    c: new featureNothing broken; request for a new capability
    toolAffects the "flutter" command-line tool. See also t: labels.
    P3Issues that are less important to the Flutter project
    on Jun 2, 2022
  2. christopherfujino commented on Jun 2, 2022

    @christopherfujino
    ContributorAuthor
  3. Jasguerrero commented on Jun 2, 2022

    @Jasguerrero
    Contributor

    SGTM

  4. jmagman commented on Sep 10, 2022

    @jmagman
    Member

    My comment from the discussion was:

    @Jasguerrero I keep running into this pattern. Can we make boolArg return a nonnull bool to simplify the code, and have it throw an exception (not toolExit since it's a developer error) if the flag doesn't exist?

    Actually, I guess I'm essentially proposing going back to the old behavior from before #101595

    They make an assumption that the argument passed to them is valid therefore if the key is not found this methods raise an ArgumentError

    That seems like the correct behavior in most cases? The key isn't there, so it should throw. There's no paper trail from #101595 to see what issue the proposed pattern was solving when the key wasn't present.

  5. christopherfujino commented on Mar 8, 2023

    @christopherfujino
    ContributorAuthor

    From a discussion in discord:

    • intArg is already deleted
    • for stringArg we should throw an ArgumentError if it wasn't parsed
    • for boolArg we should throw if it wasn't parsed and update the return type to bool
    • for stringsArg we should throw if it wasn't parsed
  6. christopherfujino commented on Mar 8, 2023

    @christopherfujino
    ContributorAuthor
  7. github-actions commented on Mar 27, 2023

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  8. locked as resolved and limited conversation to collaborators on Mar 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilitytoolAffects the "flutter" command-line tool. See also t: labels.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions