args icon indicating copy to clipboard operation
args copied to clipboard

Promote Command.argResults to be non-nullable

Open passsy opened this issue 3 years ago • 1 comments

There is no practical use for accessing argResults outside of the Command.run method. TheCommandRunner guarantees that argResults is non-null while executing Command.run. Therefore, accessing argResults always implied the value to be non-null.

Instead, an exception should be thrown when accessing argResults outside of the run method.

Before

  @override
  Future<void> run() async {
    final String? value = argResults!['value'] as String?;
    print(value);
  }

After

  @override
  Future<void> run() async {
    final String? value = argResults['value'] as String?;
    print(value);
  }

passsy avatar Nov 01 '22 01:11 passsy