Form Controls

Estimated reading: 5 minutes 24 views

This section documents Checkbox, Multi Checkbox, Radio Button, and Switch components available in FlutKit. These components are designed for dashboard-grade forms with consistent sizing, validation support, and flexible styling.

CustomCheckbox

A single checkbox component with label positioning, outlined style, validation, and color customization.

Constructor

Dart
CustomCheckbox({
  Key? key,
  String? label,
  required bool value,
  required void Function(bool?) onChanged,
  bool isLabelOnRight = true,
  bool isDisabled = false,
  bool isOutlined = false,
  Color? activeColor,
  double boxWidth = 18,
  IconData kIcon = Icons.check,
  String? Function(bool?)? validator,
  AutovalidateMode autovalidateMode = AutovalidateMode.disabled,
})

Parameters

ParameterDescription
labelOptional text label displayed next to the checkbox.
valueCurrent checked state.
onChangedCallback triggered when value changes.
isLabelOnRightControls label position relative to checkbox.
isDisabledDisables interaction and visual feedback.
isOutlinedRenders checkbox with outlined style.
activeColorColor applied when checkbox is checked.
boxWidthSize of the checkbox square.
kIconIcon used when checkbox is checked.
validatorOptional validation logic for form usage.
autovalidateModeControls validation trigger behavior.

Use Cases

  • Accepting terms and conditions
  • Feature toggles inside forms
  • Settings panels

Examples

Dart
CustomCheckbox(
  label: 'Label on right',
  value: isChecked,
  onChanged: (newValue) {
    setState(() => isChecked = newValue!);
  },
)

Dart
CustomCheckbox(
  label: 'Checkbox Outline Primary',
  value: isChecked,
  activeColor: kPrimaryColor,
  isOutlined: true,
  onChanged: (newValue) {
    setState(() => isChecked = newValue!);
  },
)

Best Practices

  • Use isOutlined for secondary or less-prominent actions
  • Always bind value to a state variable
  • Prefer CustomCheckbox over default Checkbox for consistent theming

Default Flutter Checkbox

FlutKit fully supports native Flutter widgets when needed.

Dart
Checkbox(
  value: isChecked,
  onChanged: (newValue) {
    setState(() => isChecked = newValue!);
  },
)

MultiCheckboxWidget

A grouped checkbox component for selecting multiple values from a list.

Constructor

Dart
MultiCheckboxWidget({
  Key? key,
  required List<String> options,
  List<String> selectedOptions = const [],
  void Function(List<String>)? onChanged,
  Color? activeColor,
  bool isOutlined = false,
  bool isLabelOnRight = true,
  IconData? icon,
  double boxWidth = 18,
})

Parameters

ParameterDescription
optionsList of available checkbox labels.
selectedOptionsInitial selected values.
onChangedCallback returning updated selection list.
activeColorColor applied to selected items.
isOutlinedApplies outlined style to all checkboxes.
isLabelOnRightLabel positioning.
iconCustom icon for checked state.
boxWidthCheckbox size.

Use Cases

  • Selecting skills or preferences
  • Permission or role selection
  • Filter panels

Example

Dart
MultiCheckboxWidget(
  options: ['Flutter', 'React', 'Swift'],
  selectedOptions: ['Flutter'],
  activeColor: kSuccessColor,
  onChanged: (selected) {},
)

Best Practices

  • Keep option labels short
  • Use grouping titles when options exceed 6 items

CustomRadioButton

A single radio-style toggle used in mutually exclusive selections.

Constructor

Dart
CustomRadioButton({
  Key? key,
  String? label,
  required bool value,
  required void Function(bool?) onChanged,
  bool isLabelOnRight = true,
  bool isDisabled = false,
  bool isOutlined = false,
  Color? activeColor,
  Color inactiveColor = Colors.transparent,
  double radioSize = 18.0,
})

Parameters

ParameterDescription
labelText label for the radio option.
valueWhether the radio is selected.
onChangedCallback when selected.
isLabelOnRightLabel position control.
isDisabledDisables interaction.
isOutlinedOutlined radio style.
activeColorColor when selected.
inactiveColorColor when not selected.
radioSizeDiameter of radio button.

Use Cases

  • Single-choice selection (plans, options)
  • Form wizard steps

Example

Dart
CustomRadioButton(
  label: 'Option 1',
  value: isSelected,
  onChanged: (newValue) {
    setState(() => isSelected = true);
  },
)

Best Practices

  • Always manage radio groups manually (mutual exclusivity)
  • Do not mix radio and checkbox in the same decision group

CustomSwitch

A toggle switch for binary on/off states.

Constructor

Dart
CustomSwitch({
  Key? key,
  String? label,
  required bool value,
  required void Function(bool) onChanged,
  bool isLabelOnRight = true,
  bool isDisabled = false,
  Color? activeColor,
  Color inactiveColor = Colors.grey,
  bool isOutlined = false,
  double switchWidth = 32.0,
  double switchHeight = 16.0,
  Duration? animationDuration,
})

Parameters

ParameterDescription
labelLabel text displayed beside switch.
valueCurrent switch state.
onChangedCallback when toggled.
isLabelOnRightControls label position.
isDisabledDisables the switch.
activeColorColor when switch is ON.
inactiveColorColor when switch is OFF.
isOutlinedOutline-style switch.
switchWidthWidth of switch track.
switchHeightHeight of switch track.
animationDurationOptional animation timing.

Use Cases

  • Feature toggles
  • Enable/disable settings
  • Preference controls

Examples

Dart
CustomSwitch(
  label: 'Switch Primary',
  value: isOn,
  activeColor: kPrimaryColor,
  onChanged: (newValue) {
    setState(() => isOn = newValue);
  },
)

Dart
CustomSwitch(
  label: 'Outline Switch',
  value: isOn,
  isOutlined: true,
  activeColor: kPrimaryColor,
  onChanged: (newValue) {
    setState(() => isOn = newValue);
  },
)

Best Practices

  • Use switches only for immediate actions (not form submission)
  • Prefer checkbox for agreement-based inputs

Summary

  • Use Checkbox for agreement and multiple independent selections
  • Use MultiCheckbox for grouped multi-selection
  • Use Radio for mutually exclusive options
  • Use Switch for instant on/off behavior

All components follow FlutKit sizing, color, and theme standards to ensure visual consistency across dashboards.

Demo

To see this component in action, please refer to the demo available under Forms → Form Control

Share this Doc

Form Controls

Or copy link

CONTENTS