animated_toggle_switch 0.1.0 copy "animated_toggle_switch: ^0.1.0" to clipboard
animated_toggle_switch: ^0.1.0 copied to clipboard

outdated

Simple and animated switch with multiple choices. It's an easy way if you don't want something like a DropdownMenu.

AnimatedToggleSwitch #

pub.dev github likes pub points license

buy me a coffee

If you like this package, please leave a like there on pub.dev and star on GitHub. #

Simple and animated switch with multiple choices. It's an easy way if you don't want something like a DropdownMenu.

animated_toggle_switch

Easy Usage #

Easy to use and highly customizable.

Simple Rolling Animation #

AnimatedToggleSwitch<int>.rolling(
  current: value,
  values: [0, 1, 2, 3],
  onChanged: (i) => setState(() => value = i),
  iconBuilder: iconBuilder,
)

Custom with Size Animation #

AnimatedToggleSwitch<int>.size(
  current: value,
  values: [0, 1, 2, 3],
  iconOpacity: 0.2,
  indicatorSize: Size.fromWidth(100),
  indicatorType: IndicatorType.rectangle,
  iconBuilder: (i, size, active) {
    return Row(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        Text('$i'),
        iconBuilder(i, size, active),
      ],
    );
  },
  borderColor: value.isEven ? Colors.blue : Colors.red,
  colorBuilder: (i) => i.isEven ? Colors.amber : Colors.red,
  onChanged: (i) => setState(() => value = i),
)

Custom rolling Animation #

AnimatedToggleSwitch<int>.size(
  current: value,
  values: [0, 1, 2, 3],
  iconOpacity: 1.0,
  indicatorSize: Size.fromWidth(25),
  foregroundIndicatorIconBuilder: (d, indicatorSize) {
    double transitionValue = d - d.floorToDouble();
    return Transform.rotate(
        angle: 2.0 * pi * transitionValue,
        child: Stack(children: [
          Opacity(opacity: 1 - transitionValue, child: iconBuilder(d.floor(), indicatorSize, true)),
          Opacity(opacity: transitionValue, child: iconBuilder(d.ceil(), indicatorSize, true))
        ]));
  },
  selectedIconSize: Size.square(20),
  iconSize: Size.square(20),
  indicatorType: IndicatorType.rectangle,
  iconBuilder: iconBuilder,
  colorBuilder: (i) => i.isEven ? Colors.green : Colors.tealAccent,
  onChanged: (i) => setState(() => value = i),
  borderRadius: BorderRadius.circular(8.0),
  borderColor: Colors.red,
)
543
likes
0
pub points
98%
popularity

Publisher

verified publishersplashbyte.dev

Simple and animated switch with multiple choices. It's an easy way if you don't want something like a DropdownMenu.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on animated_toggle_switch