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
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;
});
},
label: 'Receive updates',
style: style,
);
}
CheckboxStyler get style {
return CheckboxStyler()
.size(24, 24)
.icon(IconStyler().size(20).color(Colors.white))
.onSelected(CheckboxStyler().fillColor(Colors.grey.shade900))
.borderRadius(.all(const Radius.circular(3)))
.border(
BoxBorderMix.all(
BorderSideMix().color(Colors.black87).width(2),
),
);
}
}Fortal widgets
The application-owned Fortal preset provides a themed widget for this component:
Fortal variants
import 'package:flutter/material.dart';
import 'ui/ui.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: [
FortalCheckbox.surface(
selected: _isChecked,
label: 'Surface checkbox',
onChanged: (value) => setState(() => _isChecked = value ?? false),
),
FortalCheckbox.soft(
selected: _isChecked,
label: 'Soft checkbox',
onChanged: (value) => setState(() => _isChecked = value ?? false),
),
],
);
}
}See the fortalCheckboxStyle source code for all available options.
Constructor
Constructor
import 'package:flutter/material.dart';
import 'package:remix/remix.dart';
RemixCheckbox remixCheckboxConstructor({
Key? key,
required bool? selected,
ValueChanged<bool?>? onChanged,
bool enabled = true,
bool tristate = false,
IconData? checkedIcon,
IconData? uncheckedIcon,
IconData? indeterminateIcon,
FocusNode? focusNode,
bool autofocus = false,
bool enableFeedback = true,
String? label,
String? semanticLabel,
Size minimumTapTargetSize = const Size.square(48),
MouseCursor mouseCursor = SystemMouseCursors.click,
CheckboxStyler style = const CheckboxStyler.create(),
CheckboxSpec? styleSpec,
}) => throw UnimplementedError();Properties
Widget Properties
key → Key?
Optional. Controls how one widget replaces another widget in the tree.
enabled → bool
Optional. Whether the checkbox is enabled for interaction.
selected → bool?
Required. Whether the checkbox is currently selected. When [tristate] is true, can be null for indeterminate state.
tristate → bool
Optional. Whether the checkbox can be true, false, or null (indeterminate).
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. When null, the checkbox draws its built-in check glyph.
uncheckedIcon → IconData?
Optional. The icon to display when the checkbox is unchecked.
indeterminateIcon → IconData?
Optional. The icon to display when the checkbox is in indeterminate state. When null, the checkbox draws its built-in horizontal bar glyph.
enableFeedback → bool
Optional. Whether to provide haptic feedback when the checkbox is toggled. Defaults to true.
label → String?
Optional. A visible label included in the same pointer, focus, and semantics target as the checkbox. It becomes the accessible name unless semanticLabel overrides it.
style → CheckboxStyler
Optional. The style configuration for the checkbox.
styleSpec → CheckboxSpec?
Optional. The style spec for the checkbox.
focusNode → FocusNode?
Optional. The focus node for the checkbox.
semanticLabel → String?
Optional. Overrides the accessible name derived from label. Use it for icon-only checkboxes or when assistive technology needs more context than the visible label.
minimumTapTargetSize → Size
Optional. Minimum pointer, focus, and semantics target size. Defaults to Size.square(48) to satisfy common Android and iOS target-size guidance. Size.zero is an explicit compact opt-out for compositions that provide their own accessible target.
mouseCursor → MouseCursor
Optional. Cursor when hovering over the checkbox.
Style Methods
container(BoxStyler value)
Sets the checkbox container style.
indicator(IconStyler value)
Sets the checkbox indicator style.
label(TextStyler value)
Sets the visible label text style.
labelSpacing(double value)
Sets the gap between the checkbox square and its visible label. Defaults to 8 logical pixels.
labelColor(Color value)
Sets the visible label color through the generated LabelStyleMixin API.
shape(ShapeBorderMix value)
Sets the checkbox shape.
size(double width, double height)
Sets checkbox size by constraining the container.
borderRadius(BorderRadiusGeometryMix radius)
Sets checkbox border radius on the container.
border(BoxBorderMix value)
Sets checkbox border on the container.
indicatorColor(Color value)
Sets indicator color.
fillColor(Color value)
Sets checkbox fill color on the container.
alignment(Alignment value)
Sets container alignment.
onIndeterminate(CheckboxStyler value)
Style applied when the checkbox is in the indeterminate state.
onSelected(CheckboxStyler value)
Style applied when the checkbox is selected.
icon(IconStyler value)
Configures the icon style using an IconStyler.
padding(EdgeInsetsGeometryMix value)
Sets container padding.
animate(AnimationConfig value)
Sets animation configuration.
variants(List<VariantStyle<CheckboxSpec>> value)
Sets style variants.
wrap(WidgetModifierConfig value)
Applies widget modifiers such as clipping, opacity, or scaling.
modifier(WidgetModifierConfig value)
Sets the widget modifier.
call({ ... })
Creates a RemixCheckbox widget with this style applied.
constraints(BoxConstraintsMix value)
Sets size constraints on the component.
decoration(DecorationMix value)
Sets the container decoration.
margin(EdgeInsetsGeometryMix value)
Sets the container margin.
foregroundDecoration(DecorationMix value)
Sets a foreground decoration painted on top of the component.
transform(Matrix4 value, AlignmentGeometry alignment = Alignment.center)
Applies a matrix transformation to the component.
iconColor(Color value)
Sets icon color
iconSize(double value)
Sets icon size
iconOpacity(double value)
Sets icon opacity
iconWeight(double value)
Sets icon weight (useful for variable icons like Material Symbols)
iconGrade(double value)
Sets icon grade (useful for Material Icons)
iconFill(double value)
Sets icon fill (useful for Material Icons filled variants)
iconOpticalSize(double value)
Sets icon optical size (useful for Material Icons)
iconBlendMode(BlendMode value)
Sets icon blend mode
iconTextDirection(TextDirection value)
Sets icon text direction
iconShadows(List<ShadowMix> value)
Sets icon shadows
iconShadow(ShadowMix value)
Sets single icon shadow