switchButton method

DefineMTileModifier switchButton({
  1. required RxBool value,
  2. ValueChanged<bool>? onChanged,
  3. bool autoReverseState = true,
})

Implementation

DefineMTileModifier switchButton({
  required RxBool value,
  final ValueChanged<bool>? onChanged,
  bool autoReverseState = true,
}) {
  final DefineMTileModifier newModifierValue = this.copyWith(
    valueWidgetRight: Obx(
      () {
        return CupertinoSwitch(
          value: value.value,
          onChanged: (v) {
            if (autoReverseState) value.value = v;
            if (onChanged != null) onChanged(v);
          },
          activeColor: Color(0xffFD211E),
          trackColor: Colors.white.withOpacity(0.3),
        );
      },
    ),
  );
  return newModifierValue;
}