flashErrors method

void flashErrors(
  1. Object errors, {
  2. Map<String, dynamic>? input,
})

Flash validation errors and the old input for the next request. Password fields (dontFlash) and uploaded files are not kept.

req.session.flashErrors({'email': 'The email is taken'},
    input: req.all());
return back(req);

Implementation

void flashErrors(Object errors, {Map<String, dynamic>? input}) {
  flash(errorsKey, errors);
  if (input == null) return;
  flash(oldInputKey, <String, dynamic>{
    for (MapEntry<String, dynamic> entry in input.entries)
      if (!dontFlash.contains(entry.key) && _isJson(entry.value))
        entry.key: entry.value,
  });
}