Skip to content

Commit 8228fbb

Browse files
authored
Reformat NetworkRequestInspector._generateTabs to be way less indented. (#8871)
1 parent ea4aee5 commit 8228fbb

File tree

1 file changed

+53
-63
lines changed

1 file changed

+53
-63
lines changed

Diff for: packages/devtools_app/lib/src/screens/network/network_request_inspector.dart

+53-63
Original file line numberDiff line numberDiff line change
@@ -60,73 +60,63 @@ class NetworkRequestInspector extends StatelessWidget {
6060
);
6161
}
6262

63-
List<({DevToolsTab tab, Widget tabView})> _generateTabs(
64-
NetworkRequest data,
65-
) =>
66-
[
67-
(
68-
tab: _buildTab(
69-
tabName: NetworkRequestInspector._overviewTabTitle,
63+
List<({DevToolsTab tab, Widget tabView})> _generateTabs(NetworkRequest data) {
64+
final tabs = [
65+
(
66+
tab: _buildTab(tabName: NetworkRequestInspector._overviewTabTitle),
67+
tabView: NetworkRequestOverviewView(data),
68+
),
69+
if (data is DartIOHttpRequestData) ...[
70+
(
71+
tab: _buildTab(tabName: NetworkRequestInspector._headersTabTitle),
72+
tabView: HttpRequestHeadersView(data),
73+
),
74+
if (data.requestBody != null)
75+
(
76+
tab: _buildTab(
77+
tabName: NetworkRequestInspector._requestTabTitle,
78+
trailing: HttpViewTrailingCopyButton(
79+
data,
80+
(data) => data.requestBody,
7081
),
71-
tabView: NetworkRequestOverviewView(data),
7282
),
73-
if (data is DartIOHttpRequestData) ...[
74-
(
75-
tab: _buildTab(
76-
tabName: NetworkRequestInspector._headersTabTitle,
77-
),
78-
tabView: HttpRequestHeadersView(data),
79-
),
80-
if (data.requestBody != null)
81-
(
82-
tab: _buildTab(
83-
tabName: NetworkRequestInspector._requestTabTitle,
84-
trailing: HttpViewTrailingCopyButton(
85-
data,
86-
(data) => data.requestBody,
87-
),
88-
),
89-
tabView: HttpRequestView(data),
90-
),
91-
if (data.responseBody != null)
92-
(
93-
tab: _buildTab(
94-
tabName: NetworkRequestInspector._responseTabTitle,
95-
trailing: Row(
96-
children: [
97-
HttpResponseTrailingDropDown(
98-
data,
99-
currentResponseViewType:
100-
controller.currentResponseViewType,
101-
onChanged:
102-
(value) => controller.setResponseViewType = value,
103-
),
104-
HttpViewTrailingCopyButton(
105-
data,
106-
(data) => data.responseBody,
107-
),
108-
],
109-
),
110-
),
111-
tabView: HttpResponseView(
83+
tabView: HttpRequestView(data),
84+
),
85+
if (data.responseBody != null)
86+
(
87+
tab: _buildTab(
88+
tabName: NetworkRequestInspector._responseTabTitle,
89+
trailing: Row(
90+
children: [
91+
HttpResponseTrailingDropDown(
11292
data,
11393
currentResponseViewType: controller.currentResponseViewType,
94+
onChanged:
95+
(value) => controller.setResponseViewType = value,
11496
),
115-
),
116-
if (data.hasCookies)
117-
(
118-
tab: _buildTab(
119-
tabName: NetworkRequestInspector._cookiesTabTitle,
120-
),
121-
tabView: HttpRequestCookiesView(data),
122-
),
123-
],
124-
]
125-
.map(
126-
(t) => (
127-
tab: t.tab,
128-
tabView: OutlineDecoration.onlyTop(child: t.tabView),
97+
HttpViewTrailingCopyButton(data, (data) => data.responseBody),
98+
],
99+
),
129100
),
130-
)
131-
.toList();
101+
tabView: HttpResponseView(
102+
data,
103+
currentResponseViewType: controller.currentResponseViewType,
104+
),
105+
),
106+
if (data.hasCookies)
107+
(
108+
tab: _buildTab(tabName: NetworkRequestInspector._cookiesTabTitle),
109+
tabView: HttpRequestCookiesView(data),
110+
),
111+
],
112+
];
113+
return tabs
114+
.map(
115+
(t) => (
116+
tab: t.tab,
117+
tabView: OutlineDecoration.onlyTop(child: t.tabView),
118+
),
119+
)
120+
.toList();
121+
}
132122
}

0 commit comments

Comments
 (0)