Skip to content

Commit 57e5b28

Browse files
chloestefantsovaCommit Queue
authored andcommitted
[analyzer] Handle NullAwareElements in Flutter outlines
Part of #56989 Change-Id: I32557d994d16b97b8f3b40bb3d654a657338b83e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/411020 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Chloe Stefantsova <[email protected]>
1 parent b2c8b31 commit 57e5b28

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

pkg/analysis_server/lib/src/flutter/flutter_outline_computer.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ class FlutterOutlineComputer {
170170
// Ignored. It's possible that we might be able to extract
171171
// some information from some spread expressions, but it seems
172172
// unlikely enough that we're not handling it at the moment.
173+
} else if (element is NullAwareElement) {
174+
addChildrenFrom(element.value);
173175
}
174176
}
175177

pkg/analysis_server/test/src/flutter/flutter_outline_computer_test.dart

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,30 @@ class MyWidget extends StatelessWidget {
355355
''');
356356
}
357357

358+
Future<void> test_children_withNullAwareElements() async {
359+
var unitOutline = await _computeOutline('''
360+
import 'package:flutter/widgets.dart';
361+
362+
class MyWidget extends StatelessWidget {
363+
@override
364+
Widget build(BuildContext context) {
365+
return new Column(children: [
366+
const Text('aaa'),
367+
?const Text('bbb'),
368+
]);
369+
}
370+
}
371+
''');
372+
373+
expect(_toText(unitOutline), r'''
374+
(D) MyWidget
375+
(D) build
376+
Column
377+
Text
378+
Text
379+
''');
380+
}
381+
358382
Future<void> test_codeOffsetLength() async {
359383
var unitOutline = await _computeOutline('''
360384
import 'package:flutter/widgets.dart';

0 commit comments

Comments
 (0)