Checkbox
A selectable checkbox component for enabling/disabling options with support for checked, unchecked, and indeterminate states
A selectable checkbox component for toggling options on and off.
When to use this
- Multi-select lists: Allow users to select multiple items from a list
- Form inputs: Collect boolean preferences or agreement confirmations
- Settings panels: Enable/disable features or options
- Bulk actions: Select multiple items for batch operations
Basic implementation
import 'package:flutter/material.dart';
import 'package:remix/remix.dart';
class CheckboxExample extends StatefulWidget {
const CheckboxExample({super.key});
@override
State<CheckboxExample> createState() => _CheckboxExampleState();
}
class _CheckboxExampleState extends State<CheckboxExample> {
bool _isChecked = true;
@override
Widget build(BuildContext context) {
return RemixCheckbox(
selected: _isChecked,
onChanged: (value) {
setState(() {
_isChecked = value ?? false;
});
},
style: style,
);
}
RemixCheckboxStyle get style {
return RemixCheckboxStyle()
.size(24, 24)
.icon(IconStyler().size(20).color(Colors.white))
.onSelected(RemixCheckboxStyle().color(Colors.grey.shade900))
.borderRadiusAll(const Radius.circular(3))
.border(
BoxBorderMix.all(
BorderSideMix().color(Colors.black87).width(2),
),
);
}
}
Fortal styles
Remix includes Fortal-themed style helpers for this component:
import 'package:flutter/material.dart';
import 'package:remix/remix.dart';
class FortalCheckboxExample extends StatefulWidget {
const FortalCheckboxExample({super.key});
@override
State<FortalCheckboxExample> createState() => _FortalCheckboxExampleState();
}
class _FortalCheckboxExampleState extends State<FortalCheckboxExample> {
bool _isChecked = true;
@override
Widget build(BuildContext context) {
return Column(
spacing: 16,
children: [
RemixCheckbox(
selected: _isChecked,
onChanged: (value) => setState(() => _isChecked = value ?? false),
style: FortalCheckboxStyle.solid(),
),
RemixCheckbox(
selected: _isChecked,
onChanged: (value) => setState(() => _isChecked = value ?? false),
style: FortalCheckboxStyle.soft(),
),
],
);
}
}
See the FortalCheckboxStyle source code for all available options.
Constructor
const RemixCheckbox({
Key? key,
bool enabled = true,
required bool? selected,
bool tristate = false,
ValueChanged<bool?>? onChanged,
bool autofocus = false,
IconData checkedIcon = Icons.check_rounded,
IconData? uncheckedIcon,
IconData indeterminateIcon = Icons.horizontal_rule,
bool enableFeedback = true,
RemixCheckboxStyle style = const RemixCheckboxStyle.create(),
RemixCheckboxSpec? styleSpec,
FocusNode? focusNode,
String? semanticLabel,
MouseCursor mouseCursor = SystemMouseCursors.click,
})
selected → bool?
Required. Whether the checkbox is currently selected. When [tristate] is true, can be null for indeterminate state.
onChanged → ValueChanged<bool?>?
Optional. Called when the user toggles the checkbox. When tristate is true, the value can be null.
autofocus → bool
Optional. Whether the checkbox should automatically request focus when it is created.
checkedIcon → IconData
Optional. The icon to display when the checkbox is checked. Defaults to Icons.check_rounded.
indeterminateIcon → IconData
Optional. The icon to display when the checkbox is in indeterminate state. Defaults to Icons.horizontal_rule.
enableFeedback → bool
Optional. Whether to provide haptic feedback when the checkbox is toggled. Defaults to true.
onIndeterminate(RemixCheckboxStyle value)
Style applied when the checkbox is in the indeterminate state.
foregroundDecoration(DecorationMix value)
Sets a foreground decoration painted on top of the component.

