Skip to content

RKButton

A hardware-style button widget for RadioKit. Supports push (momentary) or toggle (latching) modes with optional label, icon, custom active colour, and haptic feedback.

RKButton({
required ValueChanged<bool> onChanged,
RKButtonMode mode = RKButtonMode.push,
String? onText,
String? offText,
IconData? onIcon,
IconData? offIcon,
double size = 100.0,
Color? activeColor,
bool enableHapticFeedback = true,
ValueChanged<bool>? onInteractionChanged,
double rotation = 0.0,
String? label,
})
ParameterDescription
onChangedCalled with the new logical state (true/false).
modeRKButtonMode.push for momentary press, RKButtonMode.toggle for latch.
onText / offTextText shown when the button is in the respective state.
onIcon / offIconIcons shown for each state. Defaults to power icon if none provided.
sizeDiameter of the circular button.
activeColorColour of the glow when active; defaults to theme primary.
enableHapticFeedbackEmit a light haptic pulse on interaction.
onInteractionChangedOptional callback when the user starts/stops touching the widget.
rotationVisual rotation of the widget in radians.
labelOptional text label displayed above the widget.
bool _power = false;
RKButton(
mode: RKButtonMode.toggle,
label: 'Power',
onChanged: (v) => setState(() => _power = v),
);

The button will glow with the theme’s primary colour when toggled on.