findMatch static method

(MultiBindElement, MultiBindSlot)? findMatch(
  1. BuildContext context,
  2. Type type, {
  3. String? tag,
})

Finds the nearest ancestor (MultiBindElement, MultiBindSlot) matching type (including contract/alias types) and optional tag.

Implementation

static (MultiBindElement, MultiBindSlot<dynamic>)? findMatch(
  BuildContext context,
  Type type, {
  String? tag,
}) {
  var element = context.getElementForInheritedWidgetOfExactType<MultiBinder>()
      as MultiBindElement?;
  while (element != null) {
    final slot = element.lookupSlot(type, tag: tag);
    if (slot != null) {
      return (element, slot);
    }
    element = element.parentMultiBinder;
  }
  return null;
}