Consumer property
A React component that subscribes to context changes.
Requires ReactElement Function(TValue value)
as the only child. The value argument passed to the function will
be equal to the value
prop of the closest Provider for this context above in the tree. If there is no
Provider for this context above, the value
argument will be equal to the defaultValue that was passed
to createContext.
Example:
Context MyContext = createContext();
...
class MyComponent extends UiComponent2<...> {
render() {
return (MyContext.Provider()..value = 'new context value')(
MyContext.Consumer()(
(value) {
return Dom.span()(
'$value', // Outputs: 'new context value'
);
}
);
);
}
}
Learn more: react.dev/reference/react/createContext#consumer
Implementation
final UiFactory<ConsumerProps<TValue>> Consumer;