@@ -29,12 +29,18 @@ const _rowPadding = EdgeInsets.only(
2929 bottom: _rowSpacingPadding,
3030);
3131
32- /// Helper to build ExpansionTile widgets for inspector views.
33- ExpansionTile _buildTile (String title, List <Widget > children, {Key ? key}) {
32+ /// Helper to build [ExpansionTile] widgets for inspector views.
33+ ExpansionTile _buildTile (
34+ String title,
35+ List <Widget > children, {
36+ Key ? key,
37+ bool enabled = true ,
38+ }) {
3439 return ExpansionTile (
3540 key: key,
3641 title: Text (title),
3742 initiallyExpanded: true ,
43+ enabled: enabled,
3844 children: children,
3945 );
4046}
@@ -63,30 +69,70 @@ class HttpRequestHeadersView extends StatelessWidget {
6369 return SelectionArea (
6470 child: ListView (
6571 children: [
66- _buildTile ( 'General' , [
67- for ( final entry in general.entries)
68- _Row (
69- entry : entry ,
70- constraints : constraints ,
71- isErrorValue : data.didFail && entry.key == 'statusCode' ,
72- ),
73- ], key : generalKey) ,
74- _buildTile ( 'Response Headers' , [
75- if (responseHeaders != null )
76- for ( final entry in responseHeaders.entries)
77- _Row (entry : entry, constraints : constraints ),
78- ], key : responseHeadersKey),
79- _buildTile ( 'Request Headers' , [
80- if ( requestHeaders != null )
81- for ( final entry in requestHeaders.entries)
82- _Row (entry : entry, constraints : constraints) ,
83- ], key : requestHeadersKey ),
72+ _buildHeadersTile (
73+ 'General' ,
74+ general,
75+ constraints ,
76+ key : generalKey ,
77+ ) ,
78+ _buildHeadersTile (
79+ 'Response Headers' ,
80+ responseHeaders,
81+ constraints,
82+ key : responseHeadersKey,
83+ ),
84+ _buildHeadersTile (
85+ 'Request Headers' ,
86+ requestHeaders,
87+ constraints,
88+ key : requestHeadersKey ,
89+ ),
8490 ],
8591 ),
8692 );
8793 },
8894 );
8995 }
96+
97+ ExpansionTile _buildHeadersTile (
98+ String title,
99+ Map <String , dynamic >? headers,
100+ BoxConstraints constraints, {
101+ Key ? key,
102+ }) {
103+ final hasHeaders = headers != null && headers.isNotEmpty;
104+ return _buildTile (
105+ title,
106+ [
107+ if (hasHeaders)
108+ for (final entry in headers.entries)
109+ _Row (
110+ entry: entry,
111+ constraints: constraints,
112+ isErrorValue: data.didFail && entry.key == 'statusCode' ,
113+ )
114+ else
115+ Container (
116+ width: constraints.minWidth,
117+ padding: _rowPadding,
118+ child: Row (
119+ crossAxisAlignment: CrossAxisAlignment .start,
120+ children: [
121+ Text (
122+ 'No data' ,
123+ style: TextStyle (
124+ fontStyle: FontStyle .italic,
125+ color: Colors .grey.shade600,
126+ ),
127+ ),
128+ ],
129+ ),
130+ ),
131+ ],
132+ key: key,
133+ enabled: hasHeaders,
134+ );
135+ }
90136}
91137
92138class _Row extends StatelessWidget {
0 commit comments