Skip to content

sharecube/flutter_advanced_switch

 
 

Repository files navigation

flutter_switcher

An advanced swicth widget, that can be fully customized with size, text, color, radius of corners.

Gettings Started

In the pubspec.yaml of your flutter project, add the following dependency:

dependencies:
    ...
    flutter_advanced_switch: <latest_version>

Import in your project:

import 'package:flutter_advanced_switch/flutter_advanced_switch.dart';

Basic Example

Default switch

...
AdvancedSwitch(
    value: _value, // Boolean
    onChanged: (value) => setState(() { // Callback (or null to disable)
        _value = value;
    }),
)
...

Customized switch

...
AdvancedSwitch(
    value: _value, // Boolean
    activeColor: Colors.green, // Color
    inactiveColor: Colors.grey, // Color
    activeLabel: 'ON', // String
    inactiveLabel: 'OFF',  // String
    activeTextStyle: theme.textTheme.bodyText1, // TextStyle
    inactiveTextStyle: theme.textTheme.bodyText1, // TextStyle
    borderRadius: BorderRadius.all(const Radius.circular(14)), // BorderRadius
    width: 56, // Double
    height: 28, // Double
    onChanged: (value) => setState(() { // Callback (or null to disable)
        _value = value;
    }),
),
...

DEMO

Flutter Advanced Switch Preview

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Dart 86.4%
  • Ruby 9.5%
  • Swift 2.8%
  • Other 1.3%