materialSwitchBuilder function
The default FastSwitch Material FormFieldBuilder.
Returns an InputDecorator that contains a SwitchListTile.adaptive.
Implementation
Widget materialSwitchBuilder(FormFieldState<bool> field) {
field as FastSwitchState;
final FastSwitchState(:decoration, :didChange, :enabled, :value!, :widget) =
field;
assert(widget.thumbColor == null ||
widget.thumbColor is MaterialStateProperty<Color?>);
final switchListTile = SwitchListTile.adaptive(
activeColor: widget.activeColor,
activeThumbImage: widget.activeThumbImage,
activeTrackColor: widget.activeTrackColor,
applyCupertinoTheme: widget.applyTheme,
autofocus: widget.autofocus,
contentPadding: widget.contentPadding,
controlAffinity: widget.controlAffinity,
dense: widget.dense,
dragStartBehavior: widget.dragStartBehavior,
enableFeedback: widget.enableFeedback,
focusNode: widget.focusNode,
hoverColor: widget.hoverColor,
inactiveThumbColor: widget.inactiveThumbColor,
inactiveThumbImage: widget.inactiveThumbImage,
inactiveTrackColor: widget.inactiveTrackColor,
isThreeLine: widget.isThreeLine,
materialTapTargetSize: widget.materialTapTargetSize,
mouseCursor: widget.mouseCursor,
onActiveThumbImageError: widget.onActiveThumbImageError,
onChanged: enabled ? didChange : null,
onFocusChange: widget.onFocusChange,
onInactiveThumbImageError: widget.onInactiveThumbImageError,
overlayColor: widget.overlayColor,
secondary: widget.secondary,
selected: value,
selectedTileColor: widget.selectedTileColor,
shape: widget.shapeBorder,
splashRadius: widget.splashRadius,
subtitle: widget.subtitle,
thumbColor: widget.thumbColor,
thumbIcon: widget.thumbIcon,
tileColor: widget.tileColor,
title: widget.titleBuilder(field),
trackColor: widget.trackColor,
trackOutlineColor: widget.trackOutlineColor,
value: value,
visualDensity: widget.visualDensity,
);
if (widget.showInputDecoration) {
return InputDecorator(
decoration: decoration,
child: switchListTile,
);
}
return switchListTile;
}