File tree Expand file tree Collapse file tree
lib/src/lints/prefer_first/fixes Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -44,13 +44,13 @@ class PreferFirstFix extends ParsedCorrectionProducer {
4444
4545 String _createCorrection (Expression expression) {
4646 switch (expression) {
47- case MethodInvocation (isCascaded: true ):
48- case IndexExpression (isCascaded: true ):
49- return '..first' ;
47+ case MethodInvocation (isCascaded: true , : final isNullAware ):
48+ case IndexExpression (isCascaded: true , : final isNullAware ):
49+ return isNullAware ? '?.first' : '..first' ;
5050
51- case MethodInvocation (: final target? ):
52- case IndexExpression (: final target? ):
53- return '$target .first' ;
51+ case MethodInvocation (: final target? , : final isNullAware ):
52+ case IndexExpression (: final target? , : final isNullAware ):
53+ return isNullAware ? '$ target ?.first' : '$target .first' ;
5454
5555 default :
5656 return '.first' ;
You can’t perform that action at this time.
0 commit comments