edit method

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

Implementation

Future<T?> edit(T t)async{
  final jsn=config.toDocWithId(t);
  try{
    await fbDoc(jsn[idKey]).set(jsn..remove(idKey));
  }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..[i]=t));
  return t;
}