@@ -57,6 +57,7 @@ void main() {
5757
5858 group ('on cursor location change' , () {
5959 void Function ()? listener;
60+ Completer ? getEditableArgsCalled;
6061
6162 Future <List <EditableArgument >> waitForEditableArgs () {
6263 final argsCompleter = Completer <List <EditableArgument >>();
@@ -87,6 +88,7 @@ void main() {
8788 }
8889
8990 setUp (() {
91+ getEditableArgsCalled = Completer <void >();
9092 for (final MapEntry (key: location, value: result)
9193 in locationToArgsResult.entries) {
9294 when (
@@ -95,7 +97,11 @@ void main() {
9597 textDocument: location.document,
9698 position: location.position,
9799 ),
98- ).thenAnswer ((realInvocation) => Future .value (result));
100+ ).thenAnswer ((realInvocation) {
101+ getEditableArgsCalled? .complete ();
102+ getEditableArgsCalled = Completer <void >();
103+ return Future .value (result);
104+ });
99105 }
100106 });
101107
@@ -175,6 +181,38 @@ void main() {
175181 expect (titleValue, equals ('Hello world!' ));
176182 });
177183 });
184+
185+ testWidgets ('verify does not fetch editable arguments for non-Dart files' , (
186+ tester,
187+ ) async {
188+ return await tester.runAsync (() async {
189+ // Load the property editor.
190+ await tester.pumpWidget (wrap (propertyEditor));
191+ final getEditableArgsCalledFuture = getEditableArgsCalled! .future;
192+
193+ // Send an active location changed event.
194+ eventController.add (activeLocationChangedEventNotDart);
195+
196+ // Verify it doesn't trigger a request to getEditableArgs.
197+ try {
198+ await getEditableArgsCalledFuture.timeout (
199+ const Duration (milliseconds: 100 ),
200+ );
201+ fail ('getEditableArgs was unexpectedly called.' );
202+ } on TimeoutException catch (e) {
203+ expect (e, isA <TimeoutException >());
204+ }
205+
206+ // Verify "No Dart code" message is shown.
207+ await tester.pumpAndSettle ();
208+ expect (
209+ find.textContaining (
210+ 'No Dart code found at the current cursor location.' ,
211+ ),
212+ findsOneWidget,
213+ );
214+ });
215+ });
178216 });
179217
180218 group ('inputs for editable arguments' , () {
@@ -1020,6 +1058,15 @@ final activeLocationChangedEvent4 = ActiveLocationChangedEvent(
10201058 textDocument: textDocument1,
10211059);
10221060
1061+ final notADartDocument = TextDocument (
1062+ uriAsString: '/my/fake/other.js' ,
1063+ version: 1 ,
1064+ );
1065+ final activeLocationChangedEventNotDart = ActiveLocationChangedEvent (
1066+ selections: [editorSelection1],
1067+ textDocument: notADartDocument,
1068+ );
1069+
10231070// Widget name and documentation
10241071const widgetName = 'MyFlutterWidget' ;
10251072
0 commit comments