tryTo<T> method

T? tryTo<T>()

Attempts to convert the wrapped value to type T.

Returns null if the conversion fails or if the value is null.

Implementation

T? tryTo<T>() {
  if (_value == null) return null;
  try {
    return to<T>();
  } on ConversionException {
    return null;
  }
}