Scroll<T> class
Scroll — A form field with validation, dirty tracking, and reset.
A Scroll is a Core (reactive mutable value) enhanced with form capabilities: validation, error tracking, dirty/pristine state, and reset to initial value.
Why "Scroll"?
A scroll holds ancient text — structured, validated, readable. Form fields are the modern equivalent: structured input that must be validated before it can be trusted.
Usage
class ProfilePillar extends Pillar {
late final name = scroll('', validator: (v) =>
v.isEmpty ? 'Name is required' : null,
);
late final email = scroll('', validator: (v) =>
v.contains('@') ? null : 'Invalid email',
);
bool get isFormValid => name.isValid && email.isValid;
bool get isFormDirty => name.isDirty || email.isDirty;
void submit() {
name.validate();
email.validate();
if (!isFormValid) return;
// Process form...
}
}
- Inheritance
-
- Object
- ReactiveNode
- TitanState<
T> - Scroll
- Available extensions
Constructors
Properties
-
conduits
→ List<
Conduit< T> > -
The list of currently attached Conduits (read-only view).
no setterinherited
- dependentCount → int
-
The number of active dependents.
no setterinherited
- error → String?
-
The current validation error, or
nullif valid.no setter - hashCode → int
-
The hash code for this object.
no setterinherited
- initialValue → T
-
The initial value this field was created with.
no setter
- isDirty → bool
-
Whether the current value differs from the initial value.
no setter
- isDisposed → bool
-
Whether this node has been disposed.
no setterinherited
- isPristine → bool
-
Whether the current value equals the initial value.
no setter
- isTouched → bool
-
Whether this field has been touched.
no setter
- isValid → bool
-
Whether the field has no validation error.
no setter
- isValidating → bool
-
Whether an async validation is currently in progress.
no setter
- listenerCount → int
-
The number of active listeners.
no setterinherited
-
managedNodes
→ List<
ReactiveNode> -
Returns all managed reactive nodes (for disposal by Pillar).
no setter
- name → String?
-
The debug name of this state, if provided.
no setterinherited
-
onChange
→ Stream<
void> -
Available on ReactiveNode, provided by the FluxNodeExtensions extension
Converts this node to a stream that emits on every change.no setter - previousValue → T?
-
The previous value before the most recent change.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
stream
→ Stream<
T> -
Available on TitanState<
Convenience getter for asStream().T> , provided by the FluxStateExtensions extensionno setter - value ↔ T
-
The current value.
getter/setter pairinherited
Methods
-
add(
T item) → void -
Available on TitanState<
Appends an item to the list (immutable update).List< , provided by the CoreListExtensions extensionT> > -
addAll(
Iterable< T> items) → void -
Available on TitanState<
Appends all items to the list (immutable update).List< , provided by the CoreListExtensions extensionT> > -
addConduit(
Conduit< T> conduit) → void -
Adds a Conduit to this Core's pipeline.
inherited
-
addListener(
ReactiveListener listener) → void -
Adds an imperative listener that is called when this node changes.
inherited
-
asStream(
) → Stream< T> -
Available on TitanState<
Converts this Core to a Stream that emits on every value change.T> , provided by the FluxStateExtensions extension -
clear(
) → void -
Available on TitanState<
Clears all entries.Map< , provided by the CoreMapExtensions extensionK, V> > -
clear(
) → void -
Available on TitanState<
Clears all items.List< , provided by the CoreListExtensions extensionT> > -
clearConduits(
) → void -
Removes all Conduits from this Core.
inherited
-
clearError(
) → void - Clear the error without re-validating.
-
debounce(
Duration duration, {String? name}) → DebouncedState< T> -
Available on TitanState<
Creates a debounced version of this Core.T> , provided by the FluxStateExtensions extension -
decrement(
[int amount = 1]) → void -
Available on TitanState<
Decrements the value byint> , provided by the CoreIntExtensions extensionamount(default: 1). -
decrement(
[double amount = 1.0]) → void -
Available on TitanState<
Decrements the value bydouble> , provided by the CoreDoubleExtensions extensionamount(default: 1.0). -
dispose(
) → void -
Disposes this node, clearing all dependents and listeners.
override
-
increment(
[int amount = 1]) → void -
Available on TitanState<
Increments the value byint> , provided by the CoreIntExtensions extensionamount(default: 1). -
increment(
[double amount = 1.0]) → void -
Available on TitanState<
Increments the value bydouble> , provided by the CoreDoubleExtensions extensionamount(default: 1.0). -
insert(
int index, T item) → void -
Available on TitanState<
Inserts an item atList< , provided by the CoreListExtensions extensionT> >index(immutable update). -
listen(
void callback(T value)) → void Function() -
Listens for value changes with a typed callback.
inherited
-
map<
R> (R transform(T value)) → TitanComputed< R> -
Available on TitanState<
Maps this Core's value through a transformation into a Derived.T> , provided by the FluxStateExtensions extension -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyDependents(
) → void -
Notifies all dependents and listeners that this node changed.
inherited
-
onDependencyChanged(
ReactiveNode dependency) → void -
Called when a dependency of this node has changed.
inherited
-
onTracked(
ReactiveNode source) → void -
Called when this node is registered as tracking
source.inherited -
peek(
) → T -
Returns the current value without tracking it as a dependency.
inherited
-
prism<
R> (R selector(T value), {String? name, bool equals(R previous, R next)?}) → Prism< R> -
Available on TitanState<
Creates a Prism that projects a sub-value from this Core.T> , provided by the PrismCoreExtension extension -
remove(
K key) → void -
Available on TitanState<
Removes a key (immutable update).Map< , provided by the CoreMapExtensions extensionK, V> > -
removeAt(
int index) → void -
Available on TitanState<
Removes the item atList< , provided by the CoreListExtensions extensionT> >index(immutable update). -
removeConduit(
Conduit< T> conduit) → bool -
Removes a previously added Conduit.
inherited
-
removeListener(
ReactiveListener listener) → void -
Removes a previously added listener.
inherited
-
removeWhere(
bool test(T item)) → void -
Available on TitanState<
Removes the first item matchingList< , provided by the CoreListExtensions extensionT> >test(immutable update). -
reset(
) → void - Reset to the initial value and clear the error.
-
select<
R> (R selector(T value)) → TitanComputed< R> -
Creates a TitanComputed that selects a sub-value from this state.
inherited
-
set(
K key, V val) → void -
Available on TitanState<
Sets a key-value pair (immutable update).Map< , provided by the CoreMapExtensions extensionK, V> > -
setError(
String? errorMessage) → void - Set the error manually (e.g., from server-side validation).
-
silent(
T newValue) → void -
Silently sets the value without notifying dependents.
inherited
-
throttle(
Duration duration, {String? name}) → ThrottledState< T> -
Available on TitanState<
Creates a throttled version of this Core.T> , provided by the FluxStateExtensions extension -
toggle(
) → void -
Available on TitanState<
Flips the boolean value.bool> , provided by the CoreBoolExtensions extension -
toString(
) → String -
A string representation of this object.
inherited
-
touch(
) → void - Mark this field as touched (e.g., when the user focuses and blurs it).
-
track(
) → void -
Registers the current tracker (if any) as a dependent of this node.
inherited
-
update(
T updater(T current)) → void -
Updates the value using a transformation function.
inherited
-
validate(
) → bool - Run the synchronous validator against the current value and update error.
-
validateAsync(
) → Future< bool> - Run both synchronous and asynchronous validators.
-
where(
bool predicate(T value)) → TitanComputed< bool> -
Available on TitanState<
Creates aT> , provided by the FluxStateExtensions extensionDerived<bool>that istruewhenpredicatepasses.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited