complete method

  1. @override
Future<bool> complete()
override

Implementation

@override
Future<bool> complete() async {
  // set busy
  busy = true;

  // return code
  bool ok = true;

  // set incomplete
  if (ok) status = StatusCodes.incomplete;

  // complete subforms
  // for (IForm form in forms)
  // {
  //   //ok = await form.complete();
  //   if (!ok) break;
  // }

  // validate the form
  if (ok) ok = await validate();

  // save the form and pass the validation check so validate is not called a second time. This is so the form is always saved on complete.
  hive.Form? form;
  if (ok) form = await _saveForm();

  // Post the Form
  if (ok) ok = await _postForm(form);

  // Set Clean
  if (ok == true) clean = true;

  // fire on complete event
  if (ok) ok = await EventHandler(this).execute(_onComplete);

  // set complete
  if (ok) status = StatusCodes.complete;

  // clear busy
  busy = false;

  return ok;
}