SwitchRow constructor
SwitchRow({})
Creates a switch row for preference and settings screens.
Implementation
SwitchRow({
required String label,
String? name,
String? description,
bool checked = false,
bool disabled = false,
String? className,
Map<String, Object?> props = const {},
Map<String, Object?> style = const {},
DartStyle? dartStyle,
void Function(Object event)? onChanged,
}) : super(
'div',
props: mergeComponentProps(
props,
className: className,
defaultStyle: _switchRowStyle,
dartStyle: dartStyle,
style: style,
),
children: [
FlintElement(
'div',
props: const {
'style': {'min-width': 0},
},
children: [
FlintElement(
'span',
props: const {'style': _switchRowLabelStyle},
children: [FlintText(label)],
),
if (description != null && description.trim().isNotEmpty)
FlintElement(
'span',
props: const {'style': _switchRowDescriptionStyle},
children: [FlintText(description)],
),
],
),
Switch(
name: name ?? label.toLowerCase().replaceAll(RegExp(r'\s+'), '-'),
checked: checked,
disabled: disabled,
onChanged: onChanged,
inputProps: {'aria-label': label},
dartStyle: const DartStyle(width: SizeValue.auto),
),
],
);