Configurable<T> class abstract

Base class for all configurable fields in a config editor.

Each subclass represents a specific value type (bool, string, number, etc.) and knows how to display, validate, serialize, and edit itself using the appropriate terminice prompt.

Type parameters:

  • T - The Dart type of the value this configurable holds.

Example:

final field = StringConfigurable(
  key: 'name',
  label: 'App Name',
  value: 'My App',
  validator: (v) => v.isEmpty ? 'Required' : null,
);
Implementers

Constructors

Configurable({required String key, required String label, required T value, String? description, String? hint, String formatter(T value)?, String? validator(T value)?, String? icon})
Creates a new Configurable field.

Properties

defaultTypeIcon String
The default icon for this configurable type. Override in subclasses to provide a type-specific glyph.
no setter
defaultValue → T
The original value before any edits.
final
description String?
Optional longer description shown as context when editing.
final
displayValue String
Formatted string representation of value for display in the list.
no setter
formatter String Function(T value)?
Optional display formatter. When provided, displayValue uses this instead of the default toString() representation.
final
hashCode int
The hash code for this object.
no setterinherited
hint String?
Optional hint text shown alongside the field.
final
icon String?
Custom icon override. When set, typeIcon returns this instead of the subclass default from defaultTypeIcon.
final
isModified bool
Whether the current value differs from defaultValue.
no setter
key String
Unique key used for serialization and lookup.
final
label String
Human-readable label shown in the editor list.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
typeIcon String
Glyph prefix identifying the field type in the list view. Returns the custom icon if set, otherwise defaultTypeIcon.
no setter
validator String? Function(T value)?
Optional validator. Returns an error message on failure, null on success. Returning '' is also accepted as success for backwards compatibility.
final
value ↔ T
The current value of this configurable.
getter/setter pair

Methods

edit(Terminice terminice) bool
Runs the appropriate terminice prompt to edit this field's value.
formatValue() String
Override in subclasses to provide type-specific formatting.
loadJsonValue(dynamic jsonValue) → void
Deserializes and applies a value from a JSON-compatible source.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reset() → void
Resets value back to defaultValue.
toJsonValue() → dynamic
Serializes the current value into a JSON-compatible map entry.
toString() String
A string representation of this object.
inherited
trySetValue(T candidate) bool
Sets value to candidate only when it passes validation.
validate() String?
Validates the current value. Returns null if valid, error message otherwise.
validationErrorFor(T candidate) String?
Validates a candidate value using the shared validator semantics.

Operators

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