buildCustom method
Widget
buildCustom({
- ChildWidgetBuilder? childBuilder,
- required BuildContext context,
- required JsonWidgetData data,
- Key? key,
override
Builds the widget to render to the tree. If the data
object has a
non-empty id
associated with it and the enabled property is true
then this will attach the selected value to the JsonWidgetRegistry
using the id
as the key any time the selected value is changed.
Likewise, this will set any error messages using the key '$id.error'. An empty string will be used to represent no error message.
Implementation
@override
Widget buildCustom({
ChildWidgetBuilder? childBuilder,
required BuildContext context,
required JsonWidgetData data,
Key? key,
}) {
final initialValue = value ?? (tristate != true ? false : null);
return FormField<bool>(
autovalidateMode: autovalidateMode,
enabled: enabled,
initialValue: initialValue,
onSaved: onSaved,
validator: validator == null
? null
: (value) {
final error = validator!.validate(
label: label ?? '',
value: value?.toString(),
);
data.registry.setValue(
'${data.id}.error',
error ?? '',
originator: data.id,
);
return error;
},
builder: (FormFieldState state) => MergeSemantics(
child: Semantics(
label: label ?? '',
child: Checkbox(
activeColor: activeColor,
autofocus: autofocus,
checkColor: checkColor,
fillColor: fillColor,
focusColor: focusColor,
focusNode: focusNode,
hoverColor: hoverColor,
isError: isError,
key: key,
materialTapTargetSize: materialTapTargetSize,
mouseCursor: mouseCursor,
onChanged: enabled != true
? null
: (value) {
if (onChanged != null) {
onChanged!(value);
}
state.didChange(value);
data.registry.setValue(
data.id,
value,
originator: data.id,
);
},
overlayColor: overlayColor,
shape: shape,
side: side,
splashRadius: splashRadius,
tristate: tristate,
value: state.value,
visualDensity: visualDensity,
),
),
),
);
}