DsBrandToggle class

A single-button brand toggle that flips between DsBrand.violet and DsBrand.emerald.

Violet (◆) ⇄ Emerald (🌿)

The icon swaps with the same rotate + scale + fade animation as DsThemeToggle. The icon color reflects the active brand's primary via colorScheme.primary, so the button is always in sync with the current theme.

───────────────────────────────────────────── Usage (StatefulWidget) ─────────────────────────────────────────────

class _RootState extends State<Root> {
  DsBrand _brand = DsBrand.violet;
  ThemeMode _mode = ThemeMode.system;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme:     _brand.lightTheme(),
      darkTheme: _brand.darkTheme(),
      themeMode: _mode,
      home: Scaffold(
        appBar: AppBar(
          actions: [
            DsBrandToggle(
              brand: _brand,
              onChanged: (b) => setState(() => _brand = b),
            ),
            const SizedBox(width: 8),
          ],
        ),
      ),
    );
  }
}

───────────────────────────────────────────── Usage with a ValueNotifier (no StatefulWidget needed) ─────────────────────────────────────────────

final brand = ValueNotifier(DsBrand.violet);

// In build:
ValueListenableBuilder<DsBrand>(
  valueListenable: brand,
  builder: (_, b, __) => DsBrandToggle(
    brand: b,
    onChanged: (next) => brand.value = next,
  ),
)
Inheritance

Constructors

DsBrandToggle({Key? key, required DsBrand brand, required ValueChanged<DsBrand> onChanged, double sizedBoxDimension = 48, double iconSize = 22})
const

Properties

brand DsBrand
The currently active brand.
final
hashCode int
The hash code for this object.
no setterinherited
iconSize double
The size of the icon. Defaults to 22.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
onChanged ValueChanged<DsBrand>
Called with the other DsBrand when the user taps the button.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sizedBoxDimension double
The size of the square tap target. Defaults to 48.
final

Methods

build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
override
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited