diff --git a/.vscode/launch.json b/.vscode/launch.json
index bbfd110..4e9612b 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -7,7 +7,8 @@
{
"name": "Flutter",
"request": "launch",
- "type": "dart"
+ "type": "dart",
+ "program": "example/lib/main.dart"
}
]
}
\ No newline at end of file
diff --git a/example/android/.gitignore b/example/android/.gitignore
new file mode 100644
index 0000000..0a741cb
--- /dev/null
+++ b/example/android/.gitignore
@@ -0,0 +1,11 @@
+gradle-wrapper.jar
+/.gradle
+/captures/
+/gradlew
+/gradlew.bat
+/local.properties
+GeneratedPluginRegistrant.java
+
+# Remember to never publicly share your keystore.
+# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
+key.properties
diff --git a/example/android/app/src/main/res/drawable-v21/launch_background.xml b/example/android/app/src/main/res/drawable-v21/launch_background.xml
new file mode 100644
index 0000000..f74085f
--- /dev/null
+++ b/example/android/app/src/main/res/drawable-v21/launch_background.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
diff --git a/example/android/app/src/main/res/values-night/styles.xml b/example/android/app/src/main/res/values-night/styles.xml
new file mode 100644
index 0000000..449a9f9
--- /dev/null
+++ b/example/android/app/src/main/res/values-night/styles.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
diff --git a/example/ios/.gitignore b/example/ios/.gitignore
new file mode 100644
index 0000000..151026b
--- /dev/null
+++ b/example/ios/.gitignore
@@ -0,0 +1,33 @@
+*.mode1v3
+*.mode2v3
+*.moved-aside
+*.pbxuser
+*.perspectivev3
+**/*sync/
+.sconsign.dblite
+.tags*
+**/.vagrant/
+**/DerivedData/
+Icon?
+**/Pods/
+**/.symlinks/
+profile
+xcuserdata
+**/.generated/
+Flutter/App.framework
+Flutter/Flutter.framework
+Flutter/Flutter.podspec
+Flutter/Generated.xcconfig
+Flutter/ephemeral/
+Flutter/app.flx
+Flutter/app.zip
+Flutter/flutter_assets/
+Flutter/flutter_export_environment.sh
+ServiceDefinitions.json
+Runner/GeneratedPluginRegistrant.*
+
+# Exceptions to above rules.
+!default.mode1v3
+!default.mode2v3
+!default.pbxuser
+!default.perspectivev3
diff --git a/example/ios/Flutter/flutter_export_environment.sh b/example/ios/Flutter/flutter_export_environment.sh
index 164ab8c..7ceb8a7 100755
--- a/example/ios/Flutter/flutter_export_environment.sh
+++ b/example/ios/Flutter/flutter_export_environment.sh
@@ -1,10 +1,14 @@
#!/bin/sh
# This is a generated file; do not edit or check into version control.
-export "FLUTTER_ROOT=/Users/lyy/Documents/dev_tools/flutter"
-export "FLUTTER_APPLICATION_PATH=/Users/lyy/Documents/flutter_ws/flutter_json_widget/example"
+export "FLUTTER_ROOT=/System/Volumes/Data/Files/Application/SDK/flutter2/flutter"
+export "FLUTTER_APPLICATION_PATH=/System/Volumes/Data/Files/Application/MobileApplications/Flutter/flutter_json_widget/example"
+export "COCOAPODS_PARALLEL_CODE_SIGN=true"
export "FLUTTER_TARGET=lib/main.dart"
export "FLUTTER_BUILD_DIR=build"
export "SYMROOT=${SOURCE_ROOT}/../build/ios"
-export "FLUTTER_FRAMEWORK_DIR=/Users/lyy/Documents/dev_tools/flutter/bin/cache/artifacts/engine/ios"
export "FLUTTER_BUILD_NAME=1.0.3"
export "FLUTTER_BUILD_NUMBER=1.0.3"
+export "DART_OBFUSCATION=false"
+export "TRACK_WIDGET_CREATION=false"
+export "TREE_SHAKE_ICONS=false"
+export "PACKAGE_CONFIG=.packages"
diff --git a/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
new file mode 100644
index 0000000..18d9810
--- /dev/null
+++ b/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
@@ -0,0 +1,8 @@
+
+
+
+
+ IDEDidComputeMac32BitWarning
+
+
+
diff --git a/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
new file mode 100644
index 0000000..f9b0d7c
--- /dev/null
+++ b/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
@@ -0,0 +1,8 @@
+
+
+
+
+ PreviewsEnabled
+
+
+
diff --git a/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
new file mode 100644
index 0000000..18d9810
--- /dev/null
+++ b/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
@@ -0,0 +1,8 @@
+
+
+
+
+ IDEDidComputeMac32BitWarning
+
+
+
diff --git a/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
new file mode 100644
index 0000000..f9b0d7c
--- /dev/null
+++ b/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
@@ -0,0 +1,8 @@
+
+
+
+
+ PreviewsEnabled
+
+
+
diff --git a/example/pubspec.lock b/example/pubspec.lock
index 10d7164..2ddeb1f 100644
--- a/example/pubspec.lock
+++ b/example/pubspec.lock
@@ -1,62 +1,48 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
- archive:
- dependency: transitive
- description:
- name: archive
- url: "https://pub.dartlang.org"
- source: hosted
- version: "2.0.11"
- args:
- dependency: transitive
- description:
- name: args
- url: "https://pub.dartlang.org"
- source: hosted
- version: "1.5.2"
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
source: hosted
- version: "2.4.0"
+ version: "2.6.1"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
- version: "1.0.5"
- charcode:
+ version: "2.1.0"
+ characters:
dependency: transitive
description:
- name: charcode
+ name: characters
url: "https://pub.dartlang.org"
source: hosted
- version: "1.1.2"
- collection:
+ version: "1.1.0"
+ charcode:
dependency: transitive
description:
- name: collection
+ name: charcode
url: "https://pub.dartlang.org"
source: hosted
- version: "1.14.11"
- convert:
+ version: "1.2.0"
+ clock:
dependency: transitive
description:
- name: convert
+ name: clock
url: "https://pub.dartlang.org"
source: hosted
- version: "2.1.1"
- crypto:
+ version: "1.1.0"
+ collection:
dependency: transitive
description:
- name: crypto
+ name: collection
url: "https://pub.dartlang.org"
source: hosted
- version: "2.1.3"
+ version: "1.15.0"
cupertino_icons:
dependency: "direct main"
description:
@@ -64,6 +50,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
+ fake_async:
+ dependency: transitive
+ description:
+ name: fake_async
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.2.0"
flutter:
dependency: "direct main"
description: flutter
@@ -81,55 +74,27 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
- image:
- dependency: transitive
- description:
- name: image
- url: "https://pub.dartlang.org"
- source: hosted
- version: "2.1.4"
matcher:
dependency: transitive
description:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
- version: "0.12.6"
+ version: "0.12.10"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
- version: "1.1.8"
+ version: "1.3.0"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
- version: "1.6.4"
- pedantic:
- dependency: transitive
- description:
- name: pedantic
- url: "https://pub.dartlang.org"
- source: hosted
- version: "1.8.0+1"
- petitparser:
- dependency: transitive
- description:
- name: petitparser
- url: "https://pub.dartlang.org"
- source: hosted
- version: "2.4.0"
- quiver:
- dependency: transitive
- description:
- name: quiver
- url: "https://pub.dartlang.org"
- source: hosted
- version: "2.0.5"
+ version: "1.8.0"
sky_engine:
dependency: transitive
description: flutter
@@ -141,62 +106,55 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
- version: "1.5.5"
+ version: "1.8.1"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
- version: "1.9.3"
+ version: "1.10.0"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
- version: "2.0.0"
+ version: "2.1.0"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
- version: "1.0.5"
+ version: "1.1.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
- version: "1.1.0"
+ version: "1.2.0"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
- version: "0.2.11"
+ version: "0.3.0"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
- version: "1.1.6"
+ version: "1.3.0"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
- version: "2.0.8"
- xml:
- dependency: transitive
- description:
- name: xml
- url: "https://pub.dartlang.org"
- source: hosted
- version: "3.5.0"
+ version: "2.1.0"
sdks:
- dart: ">=2.4.0 <3.0.0"
+ dart: ">=2.12.0 <3.0.0"
diff --git a/example/web/favicon.png b/example/web/favicon.png
new file mode 100644
index 0000000..8aaa46a
Binary files /dev/null and b/example/web/favicon.png differ
diff --git a/example/web/icons/Icon-192.png b/example/web/icons/Icon-192.png
new file mode 100644
index 0000000..b749bfe
Binary files /dev/null and b/example/web/icons/Icon-192.png differ
diff --git a/example/web/icons/Icon-512.png b/example/web/icons/Icon-512.png
new file mode 100644
index 0000000..88cfd48
Binary files /dev/null and b/example/web/icons/Icon-512.png differ
diff --git a/example/web/index.html b/example/web/index.html
new file mode 100644
index 0000000..0081e18
--- /dev/null
+++ b/example/web/index.html
@@ -0,0 +1,98 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ example
+
+
+
+
+
+
+
diff --git a/example/web/manifest.json b/example/web/manifest.json
new file mode 100644
index 0000000..8c01291
--- /dev/null
+++ b/example/web/manifest.json
@@ -0,0 +1,23 @@
+{
+ "name": "example",
+ "short_name": "example",
+ "start_url": ".",
+ "display": "standalone",
+ "background_color": "#0175C2",
+ "theme_color": "#0175C2",
+ "description": "A new Flutter project.",
+ "orientation": "portrait-primary",
+ "prefer_related_applications": false,
+ "icons": [
+ {
+ "src": "icons/Icon-192.png",
+ "sizes": "192x192",
+ "type": "image/png"
+ },
+ {
+ "src": "icons/Icon-512.png",
+ "sizes": "512x512",
+ "type": "image/png"
+ }
+ ]
+}
diff --git a/lib/flutter_json_widget.dart b/lib/flutter_json_widget.dart
index 74b9859..324d759 100644
--- a/lib/flutter_json_widget.dart
+++ b/lib/flutter_json_widget.dart
@@ -3,135 +3,176 @@ library flutter_json_widget;
import 'package:flutter/material.dart';
class JsonViewerWidget extends StatefulWidget {
-
final Map jsonObj;
- final bool notRoot;
+ final bool? notRoot;
- JsonViewerWidget (this.jsonObj, {this.notRoot});
+ JsonViewerWidget(this.jsonObj, {this.notRoot});
@override
JsonViewerWidgetState createState() => new JsonViewerWidgetState();
}
class JsonViewerWidgetState extends State {
-
Map openFlag = Map();
@override
Widget build(BuildContext context) {
- if(widget.notRoot??false){
- return
- Container(
+ if (widget.notRoot ?? false) {
+ return Container(
padding: EdgeInsets.only(left: 14.0),
child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: _getList())
- );
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: _getList()));
}
return Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: _getList());
+ crossAxisAlignment: CrossAxisAlignment.start, children: _getList());
}
- _getList(){
- List list = List();
- for(MapEntry entry in widget.jsonObj.entries){
+ _getList() {
+ List list = [];
+ for (MapEntry entry in widget.jsonObj.entries) {
bool ex = isExtensible(entry.value);
bool ink = isInkWell(entry.value);
- list.add(
- Row(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- 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,),
- (ex&&ink)?InkWell(
- child: Text(entry.key, style:TextStyle(color: Colors.purple[900])),
- onTap: (){
- setState(() {
- openFlag[entry.key] = !(openFlag[entry.key]??false);
- });
- }
- ):Text(entry.key, style:TextStyle(color: entry.value==null?Colors.grey:Colors.purple[900])),
- Text(':', style: TextStyle(color: Colors.grey),),
+ list.add(Row(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ 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,
+ ),
+ (ex && ink)
+ ? InkWell(
+ child: Text(entry.key,
+ style: TextStyle(color: Colors.purple[900])),
+ onTap: () {
+ setState(() {
+ openFlag[entry.key] = !(openFlag[entry.key] ?? false);
+ });
+ })
+ : Text(entry.key,
+ style: TextStyle(
+ color: entry.value == null
+ ? Colors.grey
+ : Colors.purple[900])),
+ Text(
+ ':',
+ style: TextStyle(color: Colors.grey),
+ ),
const SizedBox(width: 3),
getValueWidget(entry)
- ],)
- );
+ ],
+ ));
list.add(const SizedBox(height: 4));
- if(openFlag[entry.key]??false){
+ if (openFlag[entry.key] ?? false) {
list.add(getContentWidget(entry.value));
}
}
return list;
}
- static getContentWidget(dynamic content){
- if(content is List){
+ static getContentWidget(dynamic content) {
+ if (content is List) {
return JsonArrayViewerWidget(content, notRoot: true);
- }else{
+ } else {
return JsonViewerWidget(content, notRoot: true);
}
}
- static isInkWell(dynamic content){
- if(content == null){
+ static isInkWell(dynamic content) {
+ if (content == null) {
return false;
- }else if (content is int){
+ } else if (content is int) {
return false;
- }else if (content is String) {
+ } else if (content is String) {
return false;
} else if (content is bool) {
return false;
} else if (content is double) {
return false;
- } else if(content is List){
- if(content.isEmpty){
+ } else if (content is List) {
+ if (content.isEmpty) {
return false;
- }else {
+ } else {
return true;
}
}
return true;
}
- getValueWidget(MapEntry entry){
- if(entry.value == null){
- return Expanded(child: Text('undefined', style: TextStyle(color: Colors.grey),));
- }else if (entry.value is int){
- return Expanded(child: Text(entry.value.toString(), style: TextStyle(color: Colors.teal),));
- }else if (entry.value is String) {
- return Expanded(child: Text('\"'+entry.value+'\"', style: TextStyle(color: Colors.redAccent),));
+ getValueWidget(MapEntry entry) {
+ if (entry.value == null) {
+ return Expanded(
+ child: Text(
+ 'undefined',
+ style: TextStyle(color: Colors.grey),
+ ));
+ } else if (entry.value is int) {
+ return Expanded(
+ child: Text(
+ entry.value.toString(),
+ style: TextStyle(color: Colors.teal),
+ ));
+ } else if (entry.value is String) {
+ return Expanded(
+ child: Text(
+ '\"' + entry.value + '\"',
+ style: TextStyle(color: Colors.redAccent),
+ ));
} else if (entry.value is bool) {
- return Expanded(child: Text(entry.value.toString(), style: TextStyle(color: Colors.purple),));
+ return Expanded(
+ child: Text(
+ entry.value.toString(),
+ style: TextStyle(color: Colors.purple),
+ ));
} else if (entry.value is double) {
- return Expanded(child: Text(entry.value.toString(), style: TextStyle(color: Colors.teal),));
- } else if(entry.value is List){
- if(entry.value.isEmpty){
- return Text('Array[0]', style: TextStyle(color: Colors.grey),);
- }else {
+ return Expanded(
+ child: Text(
+ entry.value.toString(),
+ style: TextStyle(color: Colors.teal),
+ ));
+ } else if (entry.value is List) {
+ if (entry.value.isEmpty) {
+ return Text(
+ 'Array[0]',
+ style: TextStyle(color: Colors.grey),
+ );
+ } else {
return InkWell(
- child: Text('Array<${getTypeName(entry.value[0])}>[${entry.value.length}]', style: TextStyle(color: Colors.grey),),
- onTap: (){
+ child: Text(
+ 'Array<${getTypeName(entry.value[0])}>[${entry.value.length}]',
+ style: TextStyle(color: Colors.grey),
+ ),
+ onTap: () {
setState(() {
- openFlag[entry.key] = !(openFlag[entry.key]??false);
+ openFlag[entry.key] = !(openFlag[entry.key] ?? false);
});
});
}
}
return InkWell(
- child: Text('Object', style: TextStyle(color: Colors.grey),),
- onTap: (){
- setState(() {
- openFlag[entry.key] = !(openFlag[entry.key]??false);
+ child: Text(
+ 'Object',
+ style: TextStyle(color: Colors.grey),
+ ),
+ onTap: () {
+ setState(() {
+ openFlag[entry.key] = !(openFlag[entry.key] ?? false);
+ });
});
- });
}
- static isExtensible(dynamic content){
- if(content == null){
+ static isExtensible(dynamic content) {
+ if (content == null) {
return false;
- }else if(content is int){
+ } else if (content is int) {
return false;
- }else if (content is String) {
+ } else if (content is String) {
return false;
} else if (content is bool) {
return false;
@@ -141,80 +182,91 @@ class JsonViewerWidgetState extends State {
return true;
}
- static getTypeName(dynamic content){
- if (content is int){
+ static getTypeName(dynamic content) {
+ if (content is int) {
return 'int';
- }else if (content is String) {
+ } else if (content is String) {
return 'String';
} else if (content is bool) {
return 'bool';
} else if (content is double) {
return 'double';
- } else if(content is List){
+ } else if (content is List) {
return 'List';
}
return 'Object';
}
-
}
class JsonArrayViewerWidget extends StatefulWidget {
-
final List jsonArray;
- final bool notRoot;
+ final bool? notRoot;
- JsonArrayViewerWidget (this.jsonArray, {this.notRoot});
+ JsonArrayViewerWidget(this.jsonArray, {this.notRoot = false});
@override
- _JsonArrayViewerWidgetState createState() => new _JsonArrayViewerWidgetState();
+ _JsonArrayViewerWidgetState createState() =>
+ new _JsonArrayViewerWidgetState();
}
class _JsonArrayViewerWidgetState extends State {
-
- List openFlag;
+ late List openFlag;
@override
Widget build(BuildContext context) {
- if(widget.notRoot??false){
+ if (widget.notRoot ?? false) {
return Container(
padding: EdgeInsets.only(left: 14.0),
child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: _getList())
- );
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: _getList()));
}
return Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: _getList());
+ crossAxisAlignment: CrossAxisAlignment.start, children: _getList());
}
@override
- void initState(){
+ void initState() {
super.initState();
- openFlag = List(widget.jsonArray.length);
+ openFlag = List.filled(widget.jsonArray.length, false);
}
- _getList(){
- List list = List();
+ _getList() {
+ List list = [];
int i = 0;
- for(dynamic content in widget.jsonArray){
+ for (dynamic content in widget.jsonArray) {
bool ex = JsonViewerWidgetState.isExtensible(content);
bool ink = JsonViewerWidgetState.isInkWell(content);
- list.add(
- Row(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- 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,),
- (ex&&ink)?getInkWell(i):Text('[$i]', style:TextStyle(color: content==null?Colors.grey:Colors.purple[900])),
- Text(':', style: TextStyle(color: Colors.grey),),
- const SizedBox(width: 3),
- getValueWidget(content, i)
- ],
- )
- );
+ list.add(Row(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ ex
+ ? ((openFlag[i])
+ ? 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,
+ ),
+ (ex && ink)
+ ? getInkWell(i)
+ : Text('[$i]',
+ style: TextStyle(
+ color:
+ content == null ? Colors.grey : Colors.purple[900])),
+ Text(
+ ':',
+ style: TextStyle(color: Colors.grey),
+ ),
+ const SizedBox(width: 3),
+ getValueWidget(content, i)
+ ],
+ ));
list.add(const SizedBox(height: 4));
- if(openFlag[i]??false){
+ if (openFlag[i]) {
list.add(JsonViewerWidgetState.getContentWidget(content));
}
i++;
@@ -222,47 +274,75 @@ class _JsonArrayViewerWidgetState extends State {
return list;
}
- getInkWell(int index){
+ getInkWell(int index) {
return InkWell(
- child: Text('[$index]', style:TextStyle(color: Colors.purple[900])),
- onTap: (){
- setState(() {
- openFlag[index] = !(openFlag[index]??false);
+ child: Text('[$index]', style: TextStyle(color: Colors.purple[900])),
+ onTap: () {
+ setState(() {
+ openFlag[index] = !(openFlag[index]);
+ });
});
- }
- );
}
- getValueWidget(dynamic content, int index){
- if(content == null){
- return Expanded(child: Text('undefined', style: TextStyle(color: Colors.grey),));
- }else if (content is int){
- return Expanded(child: Text(content.toString(), style: TextStyle(color: Colors.teal),));
- }else if (content is String) {
- return Expanded(child: Text('\"'+content+'\"', style: TextStyle(color: Colors.redAccent),));
+ getValueWidget(dynamic content, int index) {
+ if (content == null) {
+ return Expanded(
+ child: Text(
+ 'undefined',
+ style: TextStyle(color: Colors.grey),
+ ));
+ } else if (content is int) {
+ return Expanded(
+ child: Text(
+ content.toString(),
+ style: TextStyle(color: Colors.teal),
+ ));
+ } else if (content is String) {
+ return Expanded(
+ child: Text(
+ '\"' + content + '\"',
+ style: TextStyle(color: Colors.redAccent),
+ ));
} else if (content is bool) {
- return Expanded(child: Text(content.toString(), style: TextStyle(color: Colors.purple),));
+ return Expanded(
+ child: Text(
+ content.toString(),
+ style: TextStyle(color: Colors.purple),
+ ));
} else if (content is double) {
- return Expanded(child: Text(content.toString(), style: TextStyle(color: Colors.teal),));
- } else if(content is List){
- if(content.isEmpty){
- return Text('Array[0]', style: TextStyle(color: Colors.grey),);
- }else {
+ return Expanded(
+ child: Text(
+ content.toString(),
+ style: TextStyle(color: Colors.teal),
+ ));
+ } else if (content is List) {
+ if (content.isEmpty) {
+ return Text(
+ 'Array[0]',
+ style: TextStyle(color: Colors.grey),
+ );
+ } else {
return InkWell(
- child: Text('Array<${JsonViewerWidgetState.getTypeName(content)}>[${content.length}]', style: TextStyle(color: Colors.grey),),
- onTap: (){
- setState(() {
- openFlag[index] = !(openFlag[index]??false);
+ child: Text(
+ 'Array<${JsonViewerWidgetState.getTypeName(content)}>[${content.length}]',
+ style: TextStyle(color: Colors.grey),
+ ),
+ onTap: () {
+ setState(() {
+ openFlag[index] = !(openFlag[index]);
+ });
});
- });
}
}
return InkWell(
- child: Text('Object', style: TextStyle(color: Colors.grey),),
- onTap: (){
- setState(() {
- openFlag[index] = !(openFlag[index]??false);
+ child: Text(
+ 'Object',
+ style: TextStyle(color: Colors.grey),
+ ),
+ onTap: () {
+ setState(() {
+ openFlag[index] = !(openFlag[index]);
+ });
});
- });
}
-}
\ No newline at end of file
+}
diff --git a/pubspec.lock b/pubspec.lock
index 67a7df1..ad6d1df 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -1,62 +1,55 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
- archive:
- dependency: transitive
- description:
- name: archive
- url: "https://pub.dartlang.org"
- source: hosted
- version: "2.0.11"
- args:
- dependency: transitive
- description:
- name: args
- url: "https://pub.dartlang.org"
- source: hosted
- version: "1.5.2"
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
source: hosted
- version: "2.4.0"
+ version: "2.6.1"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
- version: "1.0.5"
+ version: "2.1.0"
+ characters:
+ dependency: transitive
+ description:
+ name: characters
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.1.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
- version: "1.1.2"
- collection:
+ version: "1.2.0"
+ clock:
dependency: transitive
description:
- name: collection
+ name: clock
url: "https://pub.dartlang.org"
source: hosted
- version: "1.14.11"
- convert:
+ version: "1.1.0"
+ collection:
dependency: transitive
description:
- name: convert
+ name: collection
url: "https://pub.dartlang.org"
source: hosted
- version: "2.1.1"
- crypto:
+ version: "1.15.0"
+ fake_async:
dependency: transitive
description:
- name: crypto
+ name: fake_async
url: "https://pub.dartlang.org"
source: hosted
- version: "2.1.3"
+ version: "1.2.0"
flutter:
dependency: "direct main"
description: flutter
@@ -67,55 +60,27 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
- image:
- dependency: transitive
- description:
- name: image
- url: "https://pub.dartlang.org"
- source: hosted
- version: "2.1.4"
matcher:
dependency: transitive
description:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
- version: "0.12.6"
+ version: "0.12.10"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
- version: "1.1.8"
+ version: "1.3.0"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
- version: "1.6.4"
- pedantic:
- dependency: transitive
- description:
- name: pedantic
- url: "https://pub.dartlang.org"
- source: hosted
- version: "1.8.0+1"
- petitparser:
- dependency: transitive
- description:
- name: petitparser
- url: "https://pub.dartlang.org"
- source: hosted
- version: "2.4.0"
- quiver:
- dependency: transitive
- description:
- name: quiver
- url: "https://pub.dartlang.org"
- source: hosted
- version: "2.0.5"
+ version: "1.8.0"
sky_engine:
dependency: transitive
description: flutter
@@ -127,62 +92,55 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
- version: "1.5.5"
+ version: "1.8.1"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
- version: "1.9.3"
+ version: "1.10.0"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
- version: "2.0.0"
+ version: "2.1.0"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
- version: "1.0.5"
+ version: "1.1.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
- version: "1.1.0"
+ version: "1.2.0"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
- version: "0.2.11"
+ version: "0.3.0"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
- version: "1.1.6"
+ version: "1.3.0"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
- version: "2.0.8"
- xml:
- dependency: transitive
- description:
- name: xml
- url: "https://pub.dartlang.org"
- source: hosted
- version: "3.5.0"
+ version: "2.1.0"
sdks:
- dart: ">=2.4.0 <3.0.0"
+ dart: ">=2.12.0 <3.0.0"
diff --git a/pubspec.yaml b/pubspec.yaml
index d2d446c..6da8de3 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -5,7 +5,7 @@ author: Apigj
homepage: https://github.com/demdog/flutter_json_widget
environment:
- sdk: ">=2.1.0 <3.0.0"
+ sdk: ">=2.12.0 <3.0.0"
dependencies:
flutter:
diff --git a/test/flutter_json_widget_test.dart b/test/flutter_json_widget_test.dart
index c76e7b8..2f7e49c 100644
--- a/test/flutter_json_widget_test.dart
+++ b/test/flutter_json_widget_test.dart
@@ -1,7 +1,3 @@
-import 'package:flutter_test/flutter_test.dart';
-
-import 'package:flutter_json_widget/flutter_json_widget.dart';
-
void main() {
// test('adds one to input values', () {
// final calculator = Calculator();