context property

BuildContext? context

Get an active BuildContext.

The obtained BuildContext is one of the states_rebuilder's widgets context;

For this reason you have to use at least one of states_rebuilder's widgets.

Implementation

static BuildContext? get context {
  // if (_context != null) {
  //   return _context;
  // }

  if (_contextSet.isNotEmpty) {
    final renderObject =
        _contextSet.last.mounted ? _contextSet.last.findRenderObject() : null;
    if (renderObject != null && renderObject.attached != true) {
      _contextSet.removeLast();
      // ignore: recursive_getters
      return context;
    }
    return _contextSet.last;
  }

  return NavigationBuilder.navigate.navigatorKey.currentState?.context;
}