componentsAtLocation<T> method

  1. @override
Iterable<Component> componentsAtLocation<T>(
  1. T locationContext,
  2. List<T>? nestedContexts,
  3. T? transformContext(
    1. CoordinateTransform,
    2. T
    ),
  4. bool checkContains(
    1. Component,
    2. T
    ),
)
override

This is a generic implementation of componentsAtPoint; refer to those docs for context.

This will find components intersecting a given location context T. The context can be a single point or a more complicated structure. How to interpret the structure T is determined by the provided lambdas, transformContext and checkContains.

A simple choice of T would be a simple point (i.e. Vector2). In that case transformContext needs to be able to transform a Vector2 on the parent coordinate space into the coordinate space of a provided CoordinateTransform; and checkContains must be able to determine if a given Component "contains" the Vector2 (the definition of "contains" will vary and shall be determined by the nature of the chosen location context T).

Implementation

@override
Iterable<Component> componentsAtLocation<T>(
  T locationContext,
  List<T>? nestedContexts,
  T? Function(CoordinateTransform, T) transformContext,
  bool Function(Component, T) checkContains,
) {
  if (isRendered) {
    return super.componentsAtLocation(
      locationContext,
      nestedContexts,
      transformContext,
      checkContains,
    );
  } else {
    return const Iterable<Component>.empty();
  }
}