Skip to content

Commit 1e6d098

Browse files
committed
fix: text too long bug
1 parent b3a7718 commit 1e6d098

File tree

5 files changed

+67
-58
lines changed

5 files changed

+67
-58
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@
44

55
## [1.0.1] - TODO: Lisense upgrade
66

7+
## [1.0.2] - TODO: Fixed text too long bug
8+
79
* TODO: Describe initial release.

example/lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class _MyHomePageState extends State<MyHomePage> {
7272
],
7373
"ParaArrObj": [
7474
{
75-
"SParaString": "Work efficiently",
75+
"SParaString": "Work efficiently long words long words long words long words long words long words long words long words long words long words long words long words long words ",
7676
"SParaLong": 7996655703949312,
7777
"SParaInt": 8429,
7878
"SParaFloat": -67669103057.3056,

example/pubspec.lock

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,35 @@ packages:
55
dependency: transitive
66
description:
77
name: async
8-
url: "https://pub.dartlang.org"
8+
url: "https://pub.flutter-io.cn"
99
source: hosted
1010
version: "2.2.0"
1111
boolean_selector:
1212
dependency: transitive
1313
description:
1414
name: boolean_selector
15-
url: "https://pub.dartlang.org"
15+
url: "https://pub.flutter-io.cn"
1616
source: hosted
1717
version: "1.0.4"
1818
charcode:
1919
dependency: transitive
2020
description:
2121
name: charcode
22-
url: "https://pub.dartlang.org"
22+
url: "https://pub.flutter-io.cn"
2323
source: hosted
2424
version: "1.1.2"
2525
collection:
2626
dependency: transitive
2727
description:
2828
name: collection
29-
url: "https://pub.dartlang.org"
29+
url: "https://pub.flutter-io.cn"
3030
source: hosted
3131
version: "1.14.11"
3232
cupertino_icons:
3333
dependency: "direct main"
3434
description:
3535
name: cupertino_icons
36-
url: "https://pub.dartlang.org"
36+
url: "https://pub.flutter-io.cn"
3737
source: hosted
3838
version: "0.1.2"
3939
flutter:
@@ -57,35 +57,35 @@ packages:
5757
dependency: transitive
5858
description:
5959
name: matcher
60-
url: "https://pub.dartlang.org"
60+
url: "https://pub.flutter-io.cn"
6161
source: hosted
6262
version: "0.12.5"
6363
meta:
6464
dependency: transitive
6565
description:
6666
name: meta
67-
url: "https://pub.dartlang.org"
67+
url: "https://pub.flutter-io.cn"
6868
source: hosted
6969
version: "1.1.6"
7070
path:
7171
dependency: transitive
7272
description:
7373
name: path
74-
url: "https://pub.dartlang.org"
74+
url: "https://pub.flutter-io.cn"
7575
source: hosted
7676
version: "1.6.2"
7777
pedantic:
7878
dependency: transitive
7979
description:
8080
name: pedantic
81-
url: "https://pub.dartlang.org"
81+
url: "https://pub.flutter-io.cn"
8282
source: hosted
8383
version: "1.7.0"
8484
quiver:
8585
dependency: transitive
8686
description:
8787
name: quiver
88-
url: "https://pub.dartlang.org"
88+
url: "https://pub.flutter-io.cn"
8989
source: hosted
9090
version: "2.0.3"
9191
sky_engine:
@@ -97,56 +97,56 @@ packages:
9797
dependency: transitive
9898
description:
9999
name: source_span
100-
url: "https://pub.dartlang.org"
100+
url: "https://pub.flutter-io.cn"
101101
source: hosted
102102
version: "1.5.5"
103103
stack_trace:
104104
dependency: transitive
105105
description:
106106
name: stack_trace
107-
url: "https://pub.dartlang.org"
107+
url: "https://pub.flutter-io.cn"
108108
source: hosted
109109
version: "1.9.3"
110110
stream_channel:
111111
dependency: transitive
112112
description:
113113
name: stream_channel
114-
url: "https://pub.dartlang.org"
114+
url: "https://pub.flutter-io.cn"
115115
source: hosted
116116
version: "2.0.0"
117117
string_scanner:
118118
dependency: transitive
119119
description:
120120
name: string_scanner
121-
url: "https://pub.dartlang.org"
121+
url: "https://pub.flutter-io.cn"
122122
source: hosted
123123
version: "1.0.4"
124124
term_glyph:
125125
dependency: transitive
126126
description:
127127
name: term_glyph
128-
url: "https://pub.dartlang.org"
128+
url: "https://pub.flutter-io.cn"
129129
source: hosted
130130
version: "1.1.0"
131131
test_api:
132132
dependency: transitive
133133
description:
134134
name: test_api
135-
url: "https://pub.dartlang.org"
135+
url: "https://pub.flutter-io.cn"
136136
source: hosted
137137
version: "0.2.5"
138138
typed_data:
139139
dependency: transitive
140140
description:
141141
name: typed_data
142-
url: "https://pub.dartlang.org"
142+
url: "https://pub.flutter-io.cn"
143143
source: hosted
144144
version: "1.1.6"
145145
vector_math:
146146
dependency: transitive
147147
description:
148148
name: vector_math
149-
url: "https://pub.dartlang.org"
149+
url: "https://pub.flutter-io.cn"
150150
source: hosted
151151
version: "2.0.8"
152152
sdks:

example/pubspec.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ description: A example for json view widget.
1111
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
1212
# Read more about iOS versioning at
1313
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
14-
version: 1.0.0+1
14+
version: 1.0.2
15+
16+
description: A Json viewer widget for flutter. Shows json data in an extensible list. Makes data readable on the phone easily.
1517

1618
environment:
1719
sdk: ">=2.1.0 <3.0.0"

lib/flutter_json_widget.dart

Lines changed: 43 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)