getContentParametersAs<T extends ContentParameters> method

T? getContentParametersAs<T extends ContentParameters>()

Typed accessor for contentParameters.

Returns

The underlying parameters object only if it is of type T. This avoids the caller needing to write explicit casts. Returns null if there are no content parameters or they are of a different subtype.

Implementation

T? getContentParametersAs<T extends ContentParameters>() {
  final ContentParameters? cp = contentParameters;
  if (cp is T) {
    return cp;
  }
  return null;
}