Switcher constructor

Switcher({
  1. bool value = false,
  2. SwitcherSize size = SwitcherSize.small,
  3. Color switcherButtonColor = Colors.white,
  4. double switcherRadius = 50,
  5. double switcherButtonRadius = 50,
  6. double switcherButtonAngleTransform = 0,
  7. bool enabledSwitcherButtonRotate = true,
  8. BoxShape switcherButtonBoxShape = BoxShape.circle,
  9. Color colorOn = Colors.blue,
  10. Color colorOff = Colors.black,
  11. IconData iconOff = Icons.circle,
  12. IconData iconOn = Icons.check,
  13. Duration animationDuration = const Duration(milliseconds: 500),
  14. Curve curveType = Curves.easeInOut,
  15. Function? onTap,
  16. Function? onDoubleTap,
  17. Function? onSwipe,
  18. required dynamic onChanged(
    1. bool
    ),
})

Implementation

Switcher(
    {this.value = false,
    this.size = SwitcherSize.small,
    this.switcherButtonColor = Colors.white,
    this.switcherRadius = 50,
    this.switcherButtonRadius = 50,
    this.switcherButtonAngleTransform = 0,
    this.enabledSwitcherButtonRotate = true,
    this.switcherButtonBoxShape = BoxShape.circle,
    this.colorOn = Colors.blue,
    this.colorOff = Colors.black,
    this.iconOff = Icons.circle,
    this.iconOn = Icons.check,
    this.animationDuration = const Duration(milliseconds: 500),
    this.curveType = Curves.easeInOut,
    this.onTap,
    this.onDoubleTap,
    this.onSwipe,
    required this.onChanged})
    : _width = size == SwitcherSize.small
          ? 55
          : size == SwitcherSize.medium
              ? 80
              : 105,
      _height = size == SwitcherSize.small
          ? 20
          : size == SwitcherSize.medium
              ? 30
              : 40,
      _switcherButtonOffset = size == SwitcherSize.small
          ? switcherButtonBoxShape == BoxShape.rectangle
              ? Offset(36, 0.5)
              : switcherButtonRadius < 4
                  ? Offset(35, 0.3)
                  : Offset(34, 0.2)
          : size == SwitcherSize.medium
              ? switcherButtonBoxShape == BoxShape.rectangle
                  ? Offset(51, 0)
                  : switcherButtonRadius < 4
                      ? Offset(51, 0.5)
                      : Offset(50, 0.3)
              : switcherButtonBoxShape == BoxShape.rectangle
                  ? Offset(67, 1)
                  : switcherButtonRadius < 4
                      ? Offset(67, 0.5)
                      : Offset(65, 0.5),
      _switcherButtonSize = size == SwitcherSize.small
          ? switcherButtonBoxShape == BoxShape.rectangle
              ? 12
              : switcherButtonRadius < 4
                  ? 10
                  : 15
          : size == SwitcherSize.medium
              ? switcherButtonBoxShape == BoxShape.rectangle
                  ? 22
                  : switcherButtonRadius < 4
                      ? 17
                      : 25
              : size == SwitcherSize.large
                  ? switcherButtonBoxShape == BoxShape.rectangle
                      ? 28
                      : switcherButtonRadius < 4
                          ? 22
                          : 33
                  : 33,
      _switcherButtonIconSize = size == SwitcherSize.small
          ? switcherButtonBoxShape == BoxShape.rectangle
              ? 11
              : switcherButtonRadius < 4
                  ? 10
                  : 15
          : size == SwitcherSize.medium
              ? switcherButtonBoxShape == BoxShape.rectangle
                  ? 18
                  : switcherButtonRadius < 4
                      ? 15
                      : 21
              : size == SwitcherSize.large
                  ? switcherButtonBoxShape == BoxShape.rectangle
                      ? 24
                      : switcherButtonRadius < 4
                          ? 21
                          : 27
                  : 27,
      _switcherButtonPadding = size == SwitcherSize.small
          ? switcherButtonBoxShape == BoxShape.rectangle
              ? 4
              : switcherButtonRadius < 4
                  ? 5
                  : 2.5
          : size == SwitcherSize.medium
              ? switcherButtonBoxShape == BoxShape.rectangle
                  ? 4
                  : switcherButtonRadius < 4
                      ? 7
                      : 3
              : switcherButtonBoxShape == BoxShape.rectangle
                  ? 5
                  : switcherButtonRadius < 4
                      ? 9
                      : 4;