Custom Switch package created in Flutter

  Switch

custom_switch

Beautiful Custom Switch package created with Flutter.

The source code is 100% Dart, and everything resides in the /lib folder.

Show some heart and star the repo to support the project

computer Installation

In the dependencies: section of your pubspec.yaml, add the following line:

custom_switch: <latest_version>

Import in your project:

import 'package:custom_switch/custom_switch.dart';

grey_questionBasic Usage

class HomeScreen extends StatefulWidget {
  @override
  _HomeScreenState createState() => _HomeScreenState();
}

class _HomeScreenState extends State<HomeScreen> {

  bool status = false;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Custom Switch Example'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            CustomSwitch(
              activeColor: Colors.pinkAccent,
              value: status,
              onChanged: (value) {
                print("VALUE : $value");
                setState(() {
                  status = value;
                });
              },
            ),
            SizedBox(height: 12.0,),
            Text('Value : $status', style: TextStyle(
              color: Colors.black,
              fontSize: 20.0
            ),)
          ],
        ),
      ),
    );
  }
}

Screenshots

custom_switch

Contribute on custom switch package on GitHub

https://github.com/mohak1283/CustomSwitch

Check out implementation guide on pub.dev

https://pub.dev/packages/custom_switch