getMetadata<T> method

T? getMetadata<T>(
  1. String key
)

Retrieves metadata of specific type T

Returns null if key doesn't exist or value is of wrong type Example:

final value = context.getMetadata<int>('counter');
final config = context.getMetadata<Map<String, dynamic>>('config');

Implementation

T? getMetadata<T>(String key) {
  final value = _metadata[key];
  if (value is T) return value;
  return null;
}