getRequestByTag<T> method

T getRequestByTag<T>(
  1. String tag
)

Retrieves the result for a request identified by tag with type safety.

Returns the result cast to type T. The type parameter ensures compile-time type checking and eliminates the need for manual casting.

Example:

final user = results.getRequestByTag<UserInfo>('user');
final products = results.getRequestByTag<List<Product>>('products');

Throws:

  • ArgumentError if the tag does not exist in the results
  • The original error if the request with this tag failed

See also:

Implementation

T getRequestByTag<T>(String tag) {
  final index = _tagIndexMap[tag];
  if (index == null) {
    throw ArgumentError('Tag "$tag" not found in results');
  }
  return getRequestByIndex<T>(index);
}