add method

Future<T?> add(
  1. T t, {
  2. bool addToState = true,
  3. bool toLast = true,
})

Implementation

Future<T?> add(T t,{bool addToState=true, bool toLast=true})async{
  DocumentReference doc;
  try{
    doc=await fbCol.add(config.toDocWithId(t)..remove(idKey));
  }on FirebaseException catch(e){
    config.onException(e);
    return null;
  }
  final r = config.setId(t,doc.id);
  if(addToState&&mounted) {
    state=state.whenData((v) => List.of(addMore(v,[r],toLast: toLast)));
  }
  return r;
}