Hello, I'm developing a pure Dart application that needs to interact with Google Firestore, and, boy, was I happy when I found your package! I was surrendering to the idea of manually write a conversion method to adapt the the Firestore JSON format, but luckily I found this gem.
In any case, I'm getting this stacktrace error from Firestore when I try to create a Document using Document.fromJson:
type '_Map<dynamic, Map<String, dynamic>>' is not a subtype of type 'Map<String, dynamic>' in type cast
new MapValue.fromJson (package:googleapis/firestore/v1.dart:4961)
new Value.fromJson (package:googleapis/firestore/v1.dart:5929)
new Document.fromJson. (package:googleapis/firestore/v1.dart:3034)
MapBase.map (dart:collection/maps.dart:82)
new Document.fromJson (package:googleapis/firestore/v1.dart:3031)
createNewRequest (package:voden_cloud_api/voden_cloud_api.dart:39)
\<asynchronous suspension>
RouterEntry.invoke. (package:shelf_router/src/router_entry.dart:107)
\<asynchronous suspension>
RouterEntry.invoke (package:shelf_router/src/router_entry.dart:104)
\<asynchronous suspension>
Router.call (package:shelf_router/src/router.dart:184)
\<asynchronous suspension>
handleRequest (package:shelf/shelf_io.dart:138)
\<asynchronous suspension>
This is the piece of Dart code:
var reqString = await request.readAsString();
Map<String, dynamic> decoded = jsonDecode(reqString);
var uuid = Uuid().v1();
decoded.putIfAbsent("uuid", () => uuid);
final firestoreJsonDoc = FirestoreApiParser.convertToFirestoreDocument(json: decoded);
var document = Document.fromJson(firestoreJsonDoc);
The decoded map is like this, when printed out to console through jsonEncode of dart:convert:
Can someone give me any pointers on where the problem is? From what I can see, the "special" JSON format for Firestore seems correct, each "mapValue" has its own "fields", and the only array has its "arrayValue"-"values" pair, so I'm pretty stuck at this point
Hello, I'm developing a pure Dart application that needs to interact with Google Firestore, and, boy, was I happy when I found your package! I was surrendering to the idea of manually write a conversion method to adapt the the Firestore JSON format, but luckily I found this gem.
In any case, I'm getting this stacktrace error from Firestore when I try to create a
Document
usingDocument.fromJson
:This is the piece of Dart code:
The
decoded
map is like this, when printed out to console throughjsonEncode
ofdart:convert
:The
firestoreJsonDoc
is looking like this, again printed throughjsonEncode
ofdart:convert
:Can someone give me any pointers on where the problem is? From what I can see, the "special" JSON format for Firestore seems correct, each "mapValue" has its own "fields", and the only array has its "arrayValue"-"values" pair, so I'm pretty stuck at this point