refactor: move devtools to separate library

This commit is contained in:
Kingkor Roy Tirtho
2023-06-23 23:00:10 +06:00
parent e0c5282e19
commit 5bb89ed1fb
32 changed files with 331 additions and 45 deletions
@@ -0,0 +1,29 @@
import 'dart:convert';
import 'package:fl_query/fl_query.dart';
Object? jsonifyValue(data, JsonConfig? jsonConfig) {
switch (data.runtimeType) {
case String:
case int:
case double:
case bool:
case Null:
return data;
case Iterable:
case Map:
try {
jsonEncode(data);
return data is Iterable ? data.toList() : data;
} catch (e) {
return "[Parsing Error]: ${data.runtimeType} contains unsupported non-primitive and non-jsonEncodable value";
}
default:
if (jsonConfig == null) {
return "$data"
"\nProvide `jsonConfig: JsonConfig(...)` to enable Json view for data";
} else {
return (jsonConfig as dynamic).toJson(data);
}
}
}