Skip to content
On this page

ToggleButton

A selectable button for switching an option on or off.

ToggleButton in FluttyUIToggleButton in FluttyUI dark theme

Import

import 'package:flutter/widgets.dart';
import 'package:fluttyui/fluttyui.dart' as ui;

API Reference

The declarations below match the current FluttyUI source. Types are shown without the optional ui. import prefix.

ToggleButton

const ToggleButton({
  super.key,
  required this.onChanged,
  this.label,
  this.child,
  this.leading,
  this.trailing,
  this.isSelected = false,
  this.isDisabled = false,
  this.isFullWidth = false,
  this.variant = ToggleButtonVariant.defaultVariant,
  this.size,
  this.borderRadius,
  this.borderShape,
  this.backgroundColor,
  this.foregroundColor,
  this.selectedBackgroundColor,
  this.selectedForegroundColor,
  this.focusColor,
});
ParameterTypeRequiredDefault
keyKey?Nonull
onChangedValueChanged<bool>?Yes—
labelString?Nonull
childWidget?Nonull
leadingWidget?Nonull
trailingWidget?Nonull
isSelectedboolNofalse
isDisabledboolNofalse
isFullWidthboolNofalse
variantToggleButtonVariantNoToggleButtonVariant.defaultVariant
sizeToggleButtonSize?Nonull
borderRadiusdouble?Nonull
borderShapeBorderRadiusGeometry?Nonull
backgroundColorColor?Nonull
foregroundColorColor?Nonull
selectedBackgroundColorColor?Nonull
selectedForegroundColorColor?Nonull
focusColorColor?Nonull

Application Setup

Place components under FluttyApp to provide theme, navigation, localization, and overlay defaults. Use theme tokens for shared appearance settings.

Source

lib/src/widgets/buttons/toggle_button/toggle_button.dart

This reference is generated from the ToggleButton declaration in the FluttyUI core checkout. The component catalog lists the other available building blocks.

DartFlutter

Get started with FluttyUI