maybeFind<T> static method

T? maybeFind<T>(
  1. BuildContext context
)

Optionally find the data of the given type from the context.

  • T The type of the data.
  • context The build context.

Implementation

static T? maybeFind<T>(BuildContext context) {
  assert(context.mounted, 'The context must be mounted');
  final widget = context.findAncestorWidgetOfExactType<Data<T>>();
  if (widget == null) {
    return null;
  }
  return widget.data;
}