SwitchRow constructor

SwitchRow({
  1. required String label,
  2. String? name,
  3. String? description,
  4. bool checked = false,
  5. bool disabled = false,
  6. String? className,
  7. Map<String, Object?> props = const {},
  8. Map<String, Object?> style = const {},
  9. DartStyle? dartStyle,
  10. void onChanged(
    1. Object event
    )?,
})

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),
         ),
       ],
     );