Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,6 @@ class _NetworkProfilerControlsState extends State<_NetworkProfilerControls>
_recording = controller.recordingNotifier.value;
});
});

addAutoDisposeListener(controller.filteredData);
}

@override
Expand All @@ -205,7 +203,6 @@ class _NetworkProfilerControlsState extends State<_NetworkProfilerControls>
}

final screenWidth = ScreenSize(context).width;
final hasRequests = controller.filteredData.value.isNotEmpty;
return Column(
Comment thread
ishaquehassan marked this conversation as resolved.
children: [
Row(
Expand Down Expand Up @@ -233,7 +230,6 @@ class _NetworkProfilerControlsState extends State<_NetworkProfilerControls>
Expanded(
child: SearchField<NetworkController>(
searchController: controller,
searchFieldEnabled: hasRequests,
searchFieldWidth: screenWidth <= MediaSize.xs
? defaultSearchFieldWidth
: wideSearchFieldWidth,
Expand Down
4 changes: 3 additions & 1 deletion packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ TODO: Remove this section if there are not any updates.

## Network profiler updates

TODO: Remove this section if there are not any updates.
* Fixed the Network tab search field becoming disabled after clearing all
requests, so the search query can now be edited at any time. -
[#9855](https://github.com/flutter/devtools/pull/9855)

## Logging updates

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ void main() {

group('Network Profiler', () {
setUp(() {
// Reload the fixtures for every test. Clearing requests mutates these
// shared profiles in place (FakeVmServiceWrapper clears the same lists
// aliased by _startingRequests/_startingSockets), so a test that taps
// Clear would otherwise leave them empty for the next test.
socketProfile = loadSocketProfile();
httpProfile = loadHttpProfile();
fakeServiceConnection = FakeServiceConnectionManager(
service: FakeServiceManager.createFakeService(
socketProfile: socketProfile,
Expand Down Expand Up @@ -338,6 +344,48 @@ void main() {
// Wait to ensure all the timers have been cancelled.
await tester.pumpAndSettle(const Duration(seconds: 2));
});

testWidgetsWithWindowSize(
'search field stays enabled after clearing',
windowSize,
(WidgetTester tester) async {
// Load the network profiler screen.
controller = NetworkController();
await pumpNetworkScreen(tester);

// Populate the screen with requests.
await loadRequestsAndCheck(tester);

Finder searchFieldTextField() => find.descendant(
of: find.byType(SearchField<NetworkController>),
matching: find.byType(TextField),
);

// The search field is enabled while requests are present.
expect(
tester.widget<TextField>(searchFieldTextField()).enabled,
isTrue,
);

// Pause the profiler so polling does not repopulate the requests after
// they are cleared below.
await tester.tap(find.byType(StartStopRecordingButton));
await tester.pumpAndSettle();

// Clear the results.
await tester.tap(find.byType(ClearButton));
await tester.pumpAndSettle(const Duration(seconds: 2));
expect(controller.requests.value, isEmpty);

// The search field must stay enabled even with no requests present, so
// the query can still be edited before the next batch of requests
// arrives.
expect(
tester.widget<TextField>(searchFieldTextField()).enabled,
isTrue,
);
},
);
});

group('NetworkRequestOverviewView', () {
Expand Down
Loading