OrbitScope<T extends OrbitStore> class

Creates a store instance scoped to this widget's subtree, instead of the app-wide singleton Orbit.use<T>() returns. Useful for dialogs, tabs, nested navigators, or any reusable component that needs its own independent copy of a store's state.

OrbitScope<FormStore>(
  create: () => FormStore(),
  child: const FormDialog(),
)

Inside the subtree, OrbitBuilder<FormStore> and OrbitSelector<FormStore, ...> automatically pick up this scoped instance instead of the global singleton — no change needed at the call site. You can also reach it directly with OrbitScope.of<FormStore>(context).

Don't pass a defineStore reference (e.g. counterStore) as create — calling it returns/creates the global singleton via Orbit.use, defeating the point of scoping. Pass a bare constructor instead: create: () => CounterStore().

The store is created once, in State.initState, and disposed when this widget leaves the tree — it's never added to the global registry, so Orbit.read/reset/override don't see it, and multiple scopes of the same store type can coexist independently (e.g. two open dialogs, each with their own FormStore).

Inheritance

Constructors

OrbitScope({Key? key, required T create(), required Widget child})
const

Properties

child Widget
final
create → T Function()
Factory run once, in State.initState, to create this scope's store instance.
final
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<OrbitScope<T>>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

maybeOf<T extends OrbitStore>(BuildContext context, {bool listen = true}) → T?
Returns the nearest ancestor OrbitScope<T>'s store, or null if no such ancestor exists.
of<T extends OrbitStore>(BuildContext context, {bool listen = true}) → T
Returns the nearest ancestor OrbitScope<T>'s store.