firestore_serializable 0.0.13

  • Readme
  • Changelog
  • Example
  • Installing
  • 63

firestore_serializable #

Generate fromMap(), fromSnapshot() and toMap() methods for your firestore models using this library. Based on source_gen, similar to json_serializable

0.0.11 #

  • add missing String type conversion in .fromSnapshot & .fromMap methods

0.0.10 #

  • bugfix for Timestamps

0.0.9 #

  • support for Timestamp and DateTime, type fix with submodels

0.0.8 #

0.0.7 #

  • fix type checking for forms (see [https://github.com/dartclub/firestore_dart/issues/20])

0.0.6 #

  • improved form support (see [https://github.com/dartclub/firestore_dart/issues/20])

0.0.5 #

  • more form support (see [https://github.com/dartclub/firestore_dart/issues/20])

0.0.4 #

  • flutter form support

0.0.3 #

  • unit tests, better generators, nullable is implemented

0.0.2 #

  • example, fixed generators

0.0.1 #

  • Initial version, unstable

example/example.dart

import 'package:firestore_annotations/firestore_annotations.dart';

/* You don't have to use this firestore package, you can also use cloud_firestore or others */
import 'package:firestore_api/firestore_api.dart';

/* This annotation indicates that this is a model for firestore */
@FirestoreDocument()
class Model {
  DocumentReference selfRef;

  /* attribute annotations */

  @FirestoreAttribute(ignore: true)
  int ignoredAttribute;

  @FirestoreAttribute(alias: 'otherName')
  int number;

  @FirestoreAttribute(defaultValue: [1, 2, 3])
  List<int> intListDefaultValue;

  /* functions are ignored */
  Function function;

  /* private attributes as well */
  int _privateAttribute;

  List<int> intList;

  List<List<int>> nestedIntList;

  List<List<List<int>>> doublyNestedList;

  List<dynamic> dynamicList;

  DateTime dateTime;

  Blob blob;

  dynamic attribute;

  Model({
    this.selfRef,
    this.ignoredAttribute,
    this.number,
    this.intListDefaultValue,
    this.doublyNestedList,
    this.intList,
    this.nestedIntList,
    this.dynamicList,
    this.dateTime,
    this.blob,
    this.function,
    this.attribute,
  });

  /* constructors */
  factory Model.fromSnapshot(DocumentSnapshot snapshot) =>
      _$modelFromSnapshot(snapshot);

  factory Model.fromMap(Map<String, dynamic> data) => _$modelFromMap(data);

  Map<String, dynamic> toMap() => _$modelToMap(this);
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  firestore_serializable: ^0.0.13

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:firestore_serializable/firestore_serializable.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
32
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
63
Learn more about scoring.

We analyzed this package on May 5, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.1
  • pana: 0.13.8-dev

Health issues and suggestions

Document public APIs. (-1 points)

2 out of 2 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.6.0 <3.0.0
analyzer ^0.39.4 0.39.8
build >=0.12.0 <2.0.0 1.2.2
firestore_annotations ^0.0.2 0.0.2
source_gen ^0.9.4+7 0.9.5
Transitive dependencies
_fe_analyzer_shared 3.0.0
args 1.6.0
async 2.4.1
charcode 1.1.3
collection 1.14.12
convert 2.1.1
crypto 2.1.4
csslib 0.16.1
dart_style 1.3.6
glob 1.2.0
html 0.14.0+3
js 0.6.1+1
logging 0.11.4
meta 1.1.8
node_interop 1.0.3
node_io 1.0.1+2
package_config 1.9.3
path 1.7.0
pedantic 1.9.0
pub_semver 1.4.4
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
watcher 0.9.7+15
yaml 2.2.1
Dev dependencies
build_runner ^1.5.0
build_test ^0.10.8
build_verify ^1.1.1
firestore_api
test ^1.0.0