on_off_switch 0.0.1 copy "on_off_switch: ^0.0.1" to clipboard
on_off_switch: ^0.0.1 copied to clipboard

A Flutter package to create a custom on/off switch widget.

on_off_switch #

A Flutter package that provides an interactive on/off switch widget.

on_off_switch Demo

Installation #

Add the following line to your pubspec.yaml file:

dependencies:
  on_off_switch: ^0.0.1

Then, run:

$ flutter pub get

Usage #

Import the package in your Dart code:

import 'package:on_off_switch/on_off_switch.dart';

Use the OnOffSwitch widget in your Flutter app:

OnOffSwitch(
  value: true, // or false
  onChanged: (bool newValue) {
    // Handle the switch state change
    print('Switch value changed: $newValue');
  },
)

Example #

Check out the example folder for a simple usage example.

API Reference OnOffSwitch Properties

  • value (bool): The current state of the switch.
  • onChanged (Function(bool)): Callback function called when the switch state changes.
OnOffSwitch(
  value: true,
  onChanged: (bool newValue) {
    print('Switch value changed: $newValue');
  },
)

License #

This package is open-source and available under the MIT License.

4
likes
160
points
11
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A Flutter package to create a custom on/off switch widget.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter

More

Packages that depend on on_off_switch