getQuery<DataType, ErrorType> method

Query<DataType, ErrorType>? getQuery<DataType, ErrorType>(
  1. String key, {
  2. bool exact = true,
})

Finds the Query with the given key and returns it

exact can be used to match the key exactly or by prefix

Implementation

Query<DataType, ErrorType>? getQuery<DataType, ErrorType>(
  String key, {
  bool exact = true,
}) {
  return cache.queries
      .firstWhereOrNull(
        (query) => exact ? query.key == key : query.key.startsWith(key),
      )
      ?.cast<DataType, ErrorType>();
}