Context<T> class

The return type of createContext, Wraps ReactContext for use in Dart. Allows access to Provider and Consumer Components.

Should not be instantiated without using createContext

Example:

Context MyContext = createContext('test');

class MyContextTypeClass extends react.Component2 {
  @override
  final contextType = MyContext;

  render() {
    return react.span({}, [
      '${this.context}', // Outputs: 'test'
    ]);
  }
}

// OR

Context MyContext = createContext();

class MyClass extends react.Component2 {
  render() {
    return MyContext.Provider({'value': 'new context value'}, [
      MyContext.Consumer({}, (value) {
        return react.span({}, [
          '$value', // Outputs: 'new context value'
        ]),
      });
    ]);
  }
}

Learn more at: https://reactjs.org/docs/context.html

Properties

Consumer ReactJsContextComponentFactoryProxy
A React component that subscribes to context changes. Requires a function as a child. The function receives the current context value and returns a React node.
final
hashCode int
The hash code for this object.
no setterinherited
jsThis ReactContext
no setter
Provider ReactJsContextComponentFactoryProxy
Every Context object comes with a Provider component that allows consuming components to subscribe to context changes.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited