我该如何解决这个问题:
更喜欢使用 null 感知运算符
在这段代码上?
AnimationControllerValue halfBoundValue;
double get halfBound => halfBoundValue != null ? halfBoundValue.percentage : null;
Run Code Online (Sandbox Code Playgroud)
文档: https: //dart-lang.github.io/linter/lints/prefer_null_aware_operators.html
它建议:
AnimationControllerValue halfBoundValue;
double get halfBound => halfBoundValue?.percentage;
Run Code Online (Sandbox Code Playgroud)
会更具可读性和简洁性。
| 归档时间: |
|
| 查看次数: |
876 次 |
| 最近记录: |