maybeFindMessenger<T> static method
Find the DataMessenger that holds all of the data with the given type from the context.
TThe type of the data.contextThe build context.
Implementation
static T? maybeFindMessenger<T>(BuildContext context) {
assert(context.mounted, 'The context must be mounted');
InheritedDataHolderWidget? holder =
context.findAncestorWidgetOfExactType<InheritedDataHolder<T>>();
holder ??= context.findAncestorWidgetOfExactType<InheritedRootDataHolder>();
if (holder != null) {
return holder.holder.findData(context, T);
}
return null;
}