ofType<T> method Null safety

T? ofType<T>(
  1. [T? builder(
    1. dynamic
    )?]
)

Returns a T or null if rawValue is not a T If actual data is not T, calls builder to get one

Implementation

T? ofType<T>([T? Function(dynamic)? builder]) {
  if (_rawValue is T) {
    return _rawValue as T;
  } else if (builder != null) {
    return builder(_rawValue);
  }

  return null;
}