pulseOfByType function

PulseBase pulseOfByType(
  1. BuildContext context,
  2. Type type
)

Implementation

PulseBase<dynamic> pulseOfByType(BuildContext context, Type type) {
  PulseBase? found;
  void visitor(Element element) {
    if (element.widget is PulseProvider) {
      final provider = element.widget as PulseProvider;
      if (provider.pulse.runtimeType == type) {
        found = provider.pulse;
      }
    }
    if (found == null) element.visitChildElements(visitor);
  }

  context.visitChildElements(visitor);
  if (found == null) {
    throw FlutterError('No PulseProvider<$type> found in context');
  }
  return found!;
}