add method

void add(
  1. CompileTokenMetadata token,
  2. V value
)

Implementation

void add(CompileTokenMetadata token, V value) {
  var existing = get(token);
  if (existing != null) {
    final identifier = token.identifier;
    String name;
    if (identifier?.moduleUrl != null && identifier?.name != null) {
      name = '${identifier!.moduleUrl}::${identifier.name}';
    } else {
      name = '${token.name}';
    }
    throw BuildError.withoutContext(
      'Failed to register provider for token "$name": It already was '
      'provided, potentially automatically by the framework. This error is '
      'usually a sign you are trying to provide a token that is not valid '
      'to provide at the component level, such as "Element"; these tokens '
      'are meant to *only* be provided automatically by the framework and '
      'not manually by end-users.\n\n'
      'Please file a bug (${messages.urlFileBugs}) if you think this message '
      'is wrong or misleading.',
    );
  }
  var ak = token.assetCacheKey;
  if (ak != null) {
    _valueMap[ak] = value;
  }
}