delete method

Future<T?> delete(
  1. T t
)

Implementation

Future<T?> delete(T t)async{
  final jsn=config.toDocWithId(t);
  try{
    await fbDoc(jsn[idKey]).delete();
  }on FirebaseException catch(e){
    config.onException(e);
    return null;
  }
  final i=(state.value??[]).indexWhere((e) => getId(e)==getId(t));
  if(i!=-1)
    state=state.whenData((v) => List.of(v..removeAt(i)));
  return t;
}