Bilocator<T extends Object> class
A widget that locates a single service in a registry or an inherited model in the widget tree.
builder builds the T
.
name is a unique name key and only needed when more than one instance is registered of the same type.
If object is ChangeNotifier, dispose determines if dispose function is called. If object is not a
ChangeNotifier then the value of dispose is ignored.
child is the child widget.
location is where to store the model. Set to Location.tree to store the model as an inherited model on the
widget tree, which internally uses an InheritedWidget. Set to Location.registry to store the model as a single
service in a registry. Single services in the registry are accessible from any branch of the widget tree but can
only have one instance of a given type T
and name. Inherited models can have unlimited instances of type T
but are only accessible by descendants. See context.get
, Observer.get, and Observer.listenTo for accessing
single services and inherited models.
Bilocator also manages ChangeNotifiers. If T
is of type ChangeNotifier then a listener is added to the build
ChangeNotifier that rebuilds this Bilocator widget when ChangeNotifier.notifyListeners is called. Also, its
ChangeNotifier.dispose is called when it is unregistered.
The lifecycle of the T
object is bound to this widget, regardless of whether location is Location.tree
or Location.registry.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- Bilocator
Constructors
Properties
- builder → (T Function()?)
-
final
- child → Widget
-
final
- dispose → bool
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- location → Location
-
final
- name → String?
-
final
- 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< Bilocator< 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}) → 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
-
get<
T extends Object> ({String? name, Filter? filter}) → T -
Get a registered
T
-
isRegistered<
T extends Object> ({String? name}) → bool - Determines whether an Object is registered and therefore retrievable with Bilocator.get
-
isRegisteredByRuntimeType(
{required Type runtimeType, String? name}) → bool - Determines whether an Object is registered and therefore retrievable with Bilocator.get
-
register<
T extends Object> ({T? instance, T builder()?, String? name}) → void - Register an Object for retrieving with Bilocator.get
-
registerByRuntimeType(
{required Object instance, String? name}) → void - Register by runtimeType for when compiled type is not available.
-
unregister<
T extends Object> ({String? name, bool dispose = true}) → void - Unregister an Object so that it can no longer be retrieved with Bilocator.get
-
unregisterByRuntimeType(
{required Type runtimeType, String? name, bool dispose = true}) → void - Unregister by runtimeType for when compiled type is not available.