context property Null safety

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) {
    if (_contextSet.last.findRenderObject()?.attached != true) {
      _contextSet.removeLast();
      // ignore: recursive_getters
      return context;
    }
    return _contextSet.last;
  }

  return RM.navigate._navigatorKey.currentState?.context;
}