getParam<T> method

  1. @protected
T? getParam<T>(
  1. Comparable key
)

Gets param by key & T.

Throw ThrioException if T is not matched param scheme.

Implementation

@protected
T? getParam<T>(Comparable key) {
  // Anchor module does not need to get param scheme.
  if (this == anchor) {
    return _params[key] as T; // ignore: avoid_as
  }
  if (!_paramSchemes.keys.contains(key)) {
    return null;
  }
  final value = _params[key];
  if (value == null) {
    return null;
  }
  if (T != dynamic && T != Object && value is! T) {
    throw ThrioException('$T does not match the param scheme type: ${value.runtimeType}');
  }
  return value as T; // ignore: avoid_as
}