of static method

The state from the nearest CNFoldableScope, rebuilding the caller on every change. Falls back to state (without rebuilds) when there is no scope.

Implementation

static CNFoldableState of(BuildContext context) {
  final scope = context
      .dependOnInheritedWidgetOfExactType<_CNFoldableInherited>();
  return scope?.state ?? _state.value;
}