of static method

Provides a NesInputController down the widget tree.

Call NesController.of to get the instance, when no NesInputController is found on the widget tree, NesController.defaultController is returned.

Implementation

static NesInputController of(BuildContext context) {
  final widget = context.dependOnInheritedWidgetOfExactType<NesController>();

  if (widget == null) {
    return defaultController;
  }

  return widget.controller;
}