useForm function

FormContext useForm([
  1. String? editingId
])

Create the context for using the form.

You can determine whether it is new or existing by specifying the ID of the document to be used in the form in editingId.

First, create a context with useForm.

Pass FormContext.key to Form.

Run FormContext.validate() at the time of applying the changes to check if the values are correct.

Finally, save all changes to the specified document by running save().

Implementation

FormContext useForm([String? editingId]) {
  final uuid = useUuid();
  final context = useContext();
  return FormContext._(
    context: context,
    key: useGlobalKey<FormState>(),
    uid: editingId.isNotEmpty ? context.get(editingId!, uuid) : uuid,
    exists: editingId.isEmpty || context.arg.containsKey(editingId!),
  );
}