Field<T> class abstract

Fields are data representation of inputs that are used in the settings panel. They should be convertible to:

  1. Widget through toWidget; used to display this in the settings panel.
  2. Map through toJson; used to send a JSON-representation of the field to be interpreted by WidgetbookCloudIntegration.

Fields keep their changes in sync with WidgetbookState which syncs them with the query parameters. A Field is encoded into a query parameter using a JSON-like format (e.g. /?foo={bar:qux}), it has the following parts:

Part Value
group foo
name bar
value qux
Implementers
Annotations

Constructors

Field({required String name, required FieldType type, required T? initialValue, required FieldCodec<T> codec, @Deprecated('Fields should not be aware of their context') void onChanged(BuildContext context, T? value)?})
const

Properties

codec FieldCodec<T>
Encodes the value of Type T to a String format, to be used in a query parameter, or decodes a String query parameter back to T.
final
hashCode int
The hash code for this object.
no setterinherited
initialValue → T?
final
name String
Name of this inside the query group.
final
onChanged → void Function(BuildContext context, T? value)?
Callback for when Field's value changed through:
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
type FieldType
Type of this, helps providing some metadata about this, to help rendering proper widget by external listeners.
final

Methods

build(BuildContext context, String group) Widget
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toFullJson() Map<String, dynamic>
Same as toJson put prepends some metadata like name, type and value.
toJson() Map<String, dynamic>
Converts this into JSON representation share information about the available fields. Mostly used to support Fields on Widgetbook Cloud.
toString() String
A string representation of this object.
inherited
toWidget(BuildContext context, String group, T? value) Widget
Builds the current field into a Widget to be used for input in the side panel.
updateField(BuildContext context, String group, T value) → void
valueFrom(Map<String, String> groupMap) → T?
Extracts the value from groupMap, fallback to initialValue if not found.

Operators

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