args
args copied to clipboard
Promote Command.argResults to be non-nullable
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);
}