contextType property
Context?
contextType
Accessed once and cached when instance is created. The contextType property on a class can be assigned a ReactContext object created by React.createContext. This lets you consume the nearest current value of that Context using context.
Example:
var MyContext = createContext('test');
class MyClass extends react.Component2 {
@override
final contextType = MyContext;
render() {
return react.span({}, [
'${this.context}', // Outputs: 'test'
]);
}
}
Implementation
Context? get contextType => null;