toggle<S> static method

DiagramProperty<S, bool> toggle<S>(
  1. String key, {
  2. required String label,
  3. required bool read(
    1. S subject
    ),
  4. String? verb,
  5. DiagramPropertyArgs<S, bool>? args,
  6. S update(
    1. S subject,
    2. bool value
    )?,
  7. DiagramPropertyGroup group = DiagramPropertyGroup.general,
  8. DiagramToggleStyle style = DiagramToggleStyle.standard,
  9. DiagramIcon? icon,
  10. bool visible(
    1. S subject
    )?,
  11. bool enabled(
    1. S subject
    )?,
  12. String editLabel(
    1. bool value
    )?,
})

On or off, presented by style; a button or header toggle shows icon.

Implementation

static DiagramProperty<S, bool> toggle<S>(
  String key, {
  required String label,
  required bool Function(S subject) read,
  String? verb,
  DiagramPropertyArgs<S, bool>? args,
  S Function(S subject, bool value)? update,
  DiagramPropertyGroup group = DiagramPropertyGroup.general,
  DiagramToggleStyle style = DiagramToggleStyle.standard,
  DiagramIcon? icon,
  bool Function(S subject)? visible,
  bool Function(S subject)? enabled,
  String Function(bool value)? editLabel,
}) {
  if (icon == null &&
      (style == DiagramToggleStyle.button ||
          style == DiagramToggleStyle.header)) {
    throw ArgumentError('An icon toggle needs an icon.');
  }
  return DiagramProperty._(
    key,
    label: label,
    presentation: DiagramTogglePresentation._(style),
    read: read,
    verb: verb,
    args: args,
    update: update,
    group: group,
    icon: icon,
    visible: visible,
    enabled: enabled,
    editLabel: editLabel,
  );
}