trySave method

Future<bool> trySave(
  1. BuildContext context
)

Implementation

Future<bool> trySave(BuildContext context) async {
  FocusNode().requestFocus();

  var result = _validator.isValid(updateItemFrame.editableItem);
  if (result.isValid) {
    return _doSave(context);
  } else {
    if (result.firstInvalidPage != null &&
        ScaffoldPageController.isIn(context)) {
      ScaffoldPageController.of(context).setPage(result.firstInvalidPage!);
      await Future.delayed(Duration(milliseconds: 100));
      result = _validator.isValid(updateItemFrame.editableItem);
    }

    if (result.firstInvalidNode != null) {
      result.firstInvalidNode!.requestFocus();
    } else {
      SnackBarController.showIconAndText(
          Icons.report_gmailerrorred, "Eine Eingabe ist nicht gültig");
    }
    return false;
  }
}