of static method

Chat of(
  1. BuildContext context
)

Get the Chat instance from context.

Throws FlutterError if ChatProvider is not found.

Implementation

static Chat of(BuildContext context) {
  final provider = context.dependOnInheritedWidgetOfExactType<ChatProvider>();
  assert(() {
    if (provider == null) {
      throw FlutterError(
        'ChatProvider.of() called with a context that does not contain a '
        'ChatProvider.\n'
        'No ChatProvider ancestor could be found.',
      );
    }
    return true;
  }());
  return provider!.chat;
}