Implementing null-aware operators throughout the repository (#143804)
This pull request fixes #143803 by taking advantage of Dart's null-aware operators. And unlike `switch` expressions ([9 PRs](https://github.com/flutter/flutter/pull/143634) and counting), the Flutter codebase is already fantastic when it comes to null-aware coding. After refactoring the entire repo, all the changes involving `?.` and `??` can fit into a single pull request.
This commit is contained in:
@@ -16,20 +16,13 @@ class TestSpecs {
|
||||
int startTime;
|
||||
int? _endTime;
|
||||
|
||||
int get milliseconds {
|
||||
return endTime - startTime;
|
||||
}
|
||||
int get milliseconds => endTime - startTime;
|
||||
|
||||
set endTime(int value) {
|
||||
_endTime = value;
|
||||
}
|
||||
|
||||
int get endTime {
|
||||
if (_endTime == null) {
|
||||
return 0;
|
||||
}
|
||||
return _endTime!;
|
||||
}
|
||||
int get endTime => _endTime ?? 0;
|
||||
|
||||
String toJson() {
|
||||
return json.encode(
|
||||
|
||||
Reference in New Issue
Block a user