@@ -1085,8 +1085,11 @@ class TextViewer extends StatelessWidget {
10851085}
10861086
10871087class JsonViewer extends StatefulWidget {
1088- JsonViewer ({super .key, required this .encodedJson, this .scrollable = true })
1089- : assert (encodedJson.isNotEmpty);
1088+ const JsonViewer ({
1089+ super .key,
1090+ required this .encodedJson,
1091+ this .scrollable = true ,
1092+ });
10901093
10911094 final String encodedJson;
10921095 final bool scrollable;
@@ -1111,7 +1114,7 @@ class _JsonViewerState extends State<JsonViewer> {
11111114 }
11121115
11131116 void _updateVariablesTree () {
1114- assert (widget.encodedJson.isNotEmpty) ;
1117+ if (widget.encodedJson.isEmpty) return ;
11151118 final responseJson = json.decode (widget.encodedJson);
11161119 // Insert the JSON data into the fake service cache so we can use it with
11171120 // the `ExpandableVariable` widget.
@@ -1197,6 +1200,12 @@ class _JsonViewerState extends State<JsonViewer> {
11971200
11981201 @override
11991202 Widget build (BuildContext context) {
1203+ if (widget.encodedJson.isEmpty) {
1204+ return const Padding (
1205+ padding: EdgeInsetsGeometry .only (top: 16.0 ),
1206+ child: CenteredMessage (message: 'No JSON data' ),
1207+ );
1208+ }
12001209 Widget child = FutureBuilder (
12011210 future: _initializeTree,
12021211 builder: (context, snapshot) {
0 commit comments