Inheritable<T> class

Similar to InheritedModel provides a way to listen to certain aspects of T.

This moves the decision of whether a dependent should be updated or not to itself. As opposed to many other unconditional implementations of InheritedWidget

This uses a generic InheritableAspect to determine whether a dependent should be notified.

You can provide any implementation of InheritableAspect or use one of the built-ins such as Aspect.

Note that, contrary to InheritedModel, this does not allow depending without specifying a valid aspect. A valid aspect is determined by isSupportedAspect.

Inheritance

Constructors

Inheritable({required T value, Key? key, Widget? child})
Create an access point in widget tree to supply value to descendants.
const
Inheritable.mutable({required ValueChanged<T> onMutate, required T value, Key key, Widget child})
Mutable variant of Inheritable, users are to provide onMutate to allow value to change.
const
factory

Properties

child Widget
The widget below this widget in the tree.
finalinherited
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
overrides Set<AspectOverride<Object, T>>
Ant overrides for this Inheritable
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

copyWith({Key? key, T? value, Set<AspectOverride<Object, T>>? overrides, Widget? child}) Inheritable<T>
Create a new Inheritable of T with it's properties changed with the supplied values
createElement() → _InheritableElement<T>
Inflates this configuration to a concrete instance.
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
isSupportedAspect(InheritableAspect<T> aspect) bool
Whether given aspect is supported by this. By default all non-null aspects are supported
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
updateShouldNotify(covariant Inheritable<T> oldWidget) bool
Whether the framework should notify widgets that inherit from this widget.
override
updateShouldNotifyDependent(Inheritable<T> oldWidget, Iterable<DependableAspect<T>> dependencies) bool
Similar to InheritedModel.updateShouldNotifyDependent
valueFor<A>(InheritableAspect<T> aspect, [A transform(T)?]) → A
Get the value for given aspect. This checks for any overrides, and provides the overridden value if there is one, or _value by transform

Operators

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

Static Methods

ignoreMutation(Object? obj) → void
Convenience method when Inheritable.mutable should ignore all mutations
newOverridesSet<T>(Set<AspectOverride<Object?, T>>? other) Set<Object>
of<T>(BuildContext context, {required InheritableAspect<T> aspect, bool rebuild = true, bool nullOk = true, bool mutable = false}) Inheritable<T>?
Get the nearest enclosing Inheritable for T to context.
override<T, SubType extends T>({required SubType value, Key? key, Set<AspectOverride<Object?, T>>? overrides, ValueChanged<T>? onMutate, Widget? child, bool strict = true}) Inheritable<T>
Create an Inheritable that overrides T with given value for the widget sub-tree.
supply({required List<Inheritable<Object?>> inheritables, Widget? child, bool strict = true}) Widget
Convenience method to supply multiple Inheritables holding different values to child