@@ -39,7 +39,9 @@ class JsonViewerWidgetState extends State<JsonViewerWidget> {
3939 bool ex = isExtensible (entry.value);
4040 bool ink = isInkWell (entry.value);
4141 list.add (
42- Row (children: < Widget > [
42+ Row (
43+ crossAxisAlignment: CrossAxisAlignment .start,
44+ children: < Widget > [
4345 ex ?((openFlag[entry.key]?? false )? Icon (Icons .arrow_drop_down, size: 14 , color: Colors .grey[700 ]): Icon (Icons .arrow_right, size: 14 , color: Colors .grey[700 ])): const Icon (Icons .arrow_right, color: Color .fromARGB (0 , 0 , 0 , 0 ),size: 14 ,),
4446 (ex&& ink)? InkWell (
4547 child: Text (entry.key, style: TextStyle (color: Colors .purple[900 ])),
@@ -93,15 +95,15 @@ class JsonViewerWidgetState extends State<JsonViewerWidget> {
9395
9496 getValueWidget (MapEntry entry){
9597 if (entry.value == null ){
96- return Text ('undefined' , style: TextStyle (color: Colors .grey),);
98+ return Expanded (child : Text ('undefined' , style: TextStyle (color: Colors .grey),) );
9799 }else if (entry.value is int ){
98- return Text (entry.value.toString (), style: TextStyle (color: Colors .teal),);
100+ return Expanded (child : Text (entry.value.toString (), style: TextStyle (color: Colors .teal),) );
99101 }else if (entry.value is String ) {
100- return Text ('\" ' + entry.value+ '\" ' , style: TextStyle (color: Colors .redAccent),);
102+ return Expanded (child : Text ('\" ' + entry.value+ '\" ' , style: TextStyle (color: Colors .redAccent),) );
101103 } else if (entry.value is bool ) {
102- return Text (entry.value.toString (), style: TextStyle (color: Colors .purple),);
104+ return Expanded (child : Text (entry.value.toString (), style: TextStyle (color: Colors .purple),) );
103105 } else if (entry.value is double ) {
104- return Text (entry.value.toString (), style: TextStyle (color: Colors .teal),);
106+ return Expanded (child : Text (entry.value.toString (), style: TextStyle (color: Colors .teal),) );
105107 } else if (entry.value is List ){
106108 if (entry.value.isEmpty){
107109 return Text ('Array[0]' , style: TextStyle (color: Colors .grey),);
@@ -183,8 +185,8 @@ class _JsonArrayViewerWidgetState extends State<JsonArrayViewerWidget> {
183185 );
184186 }
185187 return Column (
186- crossAxisAlignment: CrossAxisAlignment .start,
187- children: _getList ());
188+ crossAxisAlignment: CrossAxisAlignment .start,
189+ children: _getList ());
188190 }
189191
190192 @override
@@ -200,13 +202,16 @@ class _JsonArrayViewerWidgetState extends State<JsonArrayViewerWidget> {
200202 bool ex = JsonViewerWidgetState .isExtensible (content);
201203 bool ink = JsonViewerWidgetState .isInkWell (content);
202204 list.add (
203- Row (children: < Widget > [
204- ex ?((openFlag[i]?? false )? Icon (Icons .arrow_drop_down, size: 14 , color: Colors .grey[700 ]): Icon (Icons .arrow_right, size: 14 , color: Colors .grey[700 ])): const Icon (Icons .arrow_right, color: Color .fromARGB (0 , 0 , 0 , 0 ),size: 14 ,),
205- (ex&& ink)? getInkWell (i): Text ('[$i ]' , style: TextStyle (color: content== null ? Colors .grey: Colors .purple[900 ])),
206- Text (':' , style: TextStyle (color: Colors .grey),),
207- const SizedBox (width: 3 ),
208- getValueWidget (content, i)
209- ],)
205+ Row (
206+ crossAxisAlignment: CrossAxisAlignment .start,
207+ children: < Widget > [
208+ ex ?((openFlag[i]?? false )? Icon (Icons .arrow_drop_down, size: 14 , color: Colors .grey[700 ]): Icon (Icons .arrow_right, size: 14 , color: Colors .grey[700 ])): const Icon (Icons .arrow_right, color: Color .fromARGB (0 , 0 , 0 , 0 ),size: 14 ,),
209+ (ex&& ink)? getInkWell (i): Text ('[$i ]' , style: TextStyle (color: content== null ? Colors .grey: Colors .purple[900 ])),
210+ Text (':' , style: TextStyle (color: Colors .grey),),
211+ const SizedBox (width: 3 ),
212+ getValueWidget (content, i)
213+ ],
214+ )
210215 );
211216 list.add (const SizedBox (height: 4 ));
212217 if (openFlag[i]?? false ){
@@ -219,45 +224,45 @@ class _JsonArrayViewerWidgetState extends State<JsonArrayViewerWidget> {
219224
220225 getInkWell (int index){
221226 return InkWell (
222- child: Text ('[$index ]' , style: TextStyle (color: Colors .purple[900 ])),
223- onTap: (){
224- setState (() {
225- openFlag[index] = ! (openFlag[index]?? false );
226- });
227- }
228- );
227+ child: Text ('[$index ]' , style: TextStyle (color: Colors .purple[900 ])),
228+ onTap: (){
229+ setState (() {
230+ openFlag[index] = ! (openFlag[index]?? false );
231+ });
232+ }
233+ );
229234 }
230235
231236 getValueWidget (dynamic content, int index){
232237 if (content == null ){
233- return Text ('undefined' , style: TextStyle (color: Colors .grey),);
238+ return Expanded (child : Text ('undefined' , style: TextStyle (color: Colors .grey),) );
234239 }else if (content is int ){
235- return Text (content.toString (), style: TextStyle (color: Colors .teal),);
240+ return Expanded (child : Text (content.toString (), style: TextStyle (color: Colors .teal),) );
236241 }else if (content is String ) {
237- return Text ('\" ' + content+ '\" ' , style: TextStyle (color: Colors .redAccent),);
242+ return Expanded (child : Text ('\" ' + content+ '\" ' , style: TextStyle (color: Colors .redAccent),) );
238243 } else if (content is bool ) {
239- return Text (content.toString (), style: TextStyle (color: Colors .purple),);
244+ return Expanded (child : Text (content.toString (), style: TextStyle (color: Colors .purple),) );
240245 } else if (content is double ) {
241- return Text (content.toString (), style: TextStyle (color: Colors .teal),);
246+ return Expanded (child : Text (content.toString (), style: TextStyle (color: Colors .teal),) );
242247 } else if (content is List ){
243248 if (content.isEmpty){
244249 return Text ('Array[0]' , style: TextStyle (color: Colors .grey),);
245250 }else {
246251 return InkWell (
247- child: Text ('Array<${JsonViewerWidgetState .getTypeName (content )}>[${content .length }]' , style: TextStyle (color: Colors .grey),),
248- onTap: (){
249- setState (() {
250- openFlag[index] = ! (openFlag[index]?? false );
251- });
252+ child: Text ('Array<${JsonViewerWidgetState .getTypeName (content )}>[${content .length }]' , style: TextStyle (color: Colors .grey),),
253+ onTap: (){
254+ setState (() {
255+ openFlag[index] = ! (openFlag[index]?? false );
252256 });
257+ });
253258 }
254259 }
255260 return InkWell (
256- child: Text ('Object' , style: TextStyle (color: Colors .grey),),
257- onTap: (){
258- setState (() {
259- openFlag[index] = ! (openFlag[index]?? false );
260- });
261- });
261+ child: Text ('Object' , style: TextStyle (color: Colors .grey),),
262+ onTap: (){
263+ setState (() {
264+ openFlag[index] = ! (openFlag[index]?? false );
265+ });
266+ });
262267 }
263268}
0 commit comments