FSwitchStyle.inherit constructor

FSwitchStyle.inherit({
  1. required FColors colors,
  2. required FStyle style,
})

Creates a FSwitchStyle that inherits its properties.

Implementation

factory FSwitchStyle.inherit({required FColors colors, required FStyle style}) {
  final label = FLabelStyles.inherit(style: style).horizontalStyle;
  return FSwitchStyle(
    focusColor: colors.primary,
    trackColor: FWidgetStateMap({
      // Disabled
      WidgetState.disabled & WidgetState.selected: colors.disable(colors.primary),
      WidgetState.disabled: colors.disable(colors.border),

      // Enabled / Error
      WidgetState.selected: colors.primary,
      WidgetState.any: colors.border,
    }),
    thumbColor: FWidgetStateMap.all(colors.background),
    labelTextStyle: style.formFieldStyle.labelTextStyle,
    descriptionTextStyle: style.formFieldStyle.descriptionTextStyle,
    errorTextStyle: style.formFieldStyle.errorTextStyle,
    labelPadding: label.labelPadding,
    descriptionPadding: label.descriptionPadding,
    errorPadding: label.errorPadding,
    childPadding: label.childPadding,
  );
}