fireship.io
fireship.io copied to clipboard
courses/flutter-firebase/firestore-json-serializable/
JSON Serializable
How to use JSON Serializable with Firestore
https://fireship.io/courses/flutter-firebase/intro-flutter-create/
Could you give me a little hint how to use for example a DateTime Field with this approach? I tried: class Test { DateTime testdate; ... Test( {this.testdate = const DateTime() , ...
Then i get "const_with_non_const - The constructor being called isn't a const constructor. Try removing 'const' from the constructor invocation."
When i try: this.testdate = DateTime() i get: "value": "non_constant_default_value", "message": "The default value of an optional parameter must be constant.", "value": "not_enough_positional_arguments", "message": "1 positional argument(s) expected, but 0 found.\nTry adding the missing arguments.",
I even tried DateTime.now() but still get errors.
As of August, 2022, the command should be
flutter pub run build_runner build
The versions that work for me are
json_annotation: 4.6.0
build_runner: 2.2.0
json_serializable: 6.3.1