Animated switch


Customizable animated switch widget for flutter apps
Custom Switch button made to allow you to customize colors, icons, and off/on text.

Manage the widget states in the same way you do with the classical material's switch widget.

style: lint


Quick Start

Import this library into your project:

animated_switch: ^latest_version

Or do:

$ flutter pub add animated_switch

Basic Implementation

Using the callback


AnimatedSwitch(
  onChanged: (bool state) {
    print('turned ${(state) ? 'on' : 'off'}');
  },
),

More possibilities

  • Change colors

    AnimatedSwitch(    
        ...
        colorOn: Colors.blue,
        colorOff: Colors.grey,
        indicatorColor: Colors.limeAccent,
    )
    

  • Change icons

    AnimatedSwitch(
        ...
        iconOff: Icons.lock_open,
        iconOn: Icons.lock,
    )
    

  • Create custom text indicators

    AnimatedSwitch(    
        ...
        textOn: "On",
        textOff: "Off",
        textStyle: TextStyle(color: Colors.white, fontSize: 20),
    )
    

Previews

Libraries

animated_switch