tryData<T> method

T? tryData<T>(
  1. String key, {
  2. T? def,
})

Retrieves the value of key as a String from the request data. If the value is not found, returns def (default value). This method is used to retrieve string values from the request data.

Implementation

T? tryData<T>(String key, {T? def}) {
  if (hasData(key)) {
    return get<T>(key, def: def);
  } else {
    return def;
  }
}