CwToggleButton Documentation
Overview
CwToggleButton is a customizable toggle button widget for Flutter, designed to provide a simple way to display a switch between two states, such as "active" and "inactive". This widget is highly configurable, allowing you to adjust its size, colors, text, icons, and tooltips. It supports both a basic toggle button (CwToggleButton.widget) and a more complex toggle button embedded within a tile (CwToggleButton.tile).
Toggle Variants:
-
Basic Toggle Button (
CwToggleButton.widget)
A standalone toggle button that offers a clean and simple design for toggling between two states. -
Toggle Button with Tile Layout (
CwToggleButton.tile)
A toggle button integrated into a tile layout with additional customization options, such as title, subtitle, leading/trailing widgets, padding, and background color.
Parameters
Common Parameters for Both Variants
value: The current state of the toggle button (truefor active,falsefor inactive).onChanged: A callback function triggered when the toggle's value changes. It takes aboolparameter.height: The height of the toggle button (default:35).fontSize: The font size for the text displayed on the toggle (default:16).activeColor: The background color when the toggle is active (default:Colors.blue).inactiveColor: The background color when the toggle is inactive (default:Colors.grey).activeText: The text displayed when the toggle is active (default: empty string).inactiveText: The text displayed when the toggle is inactive (default: empty string).activeTextColor: The color of the text when the toggle is active (default:Colors.white).inactiveTextColor: The color of the text when the toggle is inactive (default:Colors.white).activeThumbColor: The color of the thumb (circle) when the toggle is active (default:Colors.white).inactiveThumbColor: The color of the thumb (circle) when the toggle is inactive (default:Colors.white).activeTooltip: The tooltip text displayed when the toggle is active.inactiveTooltip: The tooltip text displayed when the toggle is inactive.activeThumbIcon: Custom icon to display in the thumb when the toggle is active.inactiveThumbIcon: Custom icon to display in the thumb when the toggle is inactive.activeBorder: Border around the toggle when it is active.inactiveBorder: Border around the toggle when it is inactive.
Additional Parameters for CwToggleButton.tile
contentWidget: Custom widget to display inside the toggle button tile.title: The main title text to display in the tile.subTitle: The subtitle text to display in the tile.leadingWidget: A widget to display at the leading side of the tile.trailingWidget: A widget to display at the trailing side of the tile.toggleTilePadding: Padding for the toggle button tile.toggleTileBackgroundColor: Background color for the toggle button tile.toggleTileGradient: Gradient color for the background of the toggle button tile.toggleTileHeight: Height of the toggle button tile.toggleTileWidth: Width of the toggle button tile.toggleTileBorderRadius: Border radius for the toggle button tile.toggleTileBorder: Border for the toggle button tile.togglePosition: Position of the toggle within the tile (default:TogglePosition.leadingTop).