firestore_api_parser 1.0.2 firestore_api_parser: ^1.0.2 copied to clipboard
A Flutter and Dart plugin allowing you to convert the JSON format used by firestore to represent its documents or collections to the conventional JSON data format
example/firestore_api_parser_example.dart
import 'package:firestore_api_parser/firestore_api_parser.dart';
import 'agent.dart';
void main() {
final missions = <Map<String, String>>[
{'2022': 'No Time To Die'},
{'2015': 'Spectre'},
{'2006': 'Casino Royale'},
];
final names = {'lastname': 'BOND', 'firstname': 'James', 'initial': 'JB'};
final jb = Agent(
names: names,
missions: missions,
status: 'In service',
round: 20.5,
timestamp: DateTime.parse('2021-10-07T19:00:00Z'),
storageRef: 'projects/my_great_project/databases/(default)/documents/USERS/an_user_id',
nullable: null,
coordinates: {'latitude': -64, 'longitude': -86});
final fParser = FirestoreApiParser();
final doc = fParser.toFirestoreJson(json: jb.toJson());
print(doc);
print('\n------------SEPARATOR------------\n');
final json = fParser.toJson(firestoreJson: doc);
print(json);
}