validate method

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

Implementation

@override
Future<bool> validate() async {
  bool ok = true;

  // force commits on focused field
  WidgetModel.unfocus();

  // get all fields in alarm state
  var list = _getAlarmingFields();
  if (list.isNotEmpty) ok = false;

  //taost and scroll
  if (list.isNotEmpty) {
    // display toast message
    //String msg = phrase.warningAlarms.replaceAll('{#}', list.length.toString());
    //System.toast("${phrase.warning} $msg");

    // scroll to the field
    var view = findListenerOfExactType(FormViewState);
    if (view is FormViewState) view.show(list.first);
  }

  // execute validation events
  if (ok) {
    await EventHandler(this).execute(_onValidate);
  } else {
    await EventHandler(this).execute(_onInvalid);
  }

  return ok;
}