toggle_switch 0.1.2 copy "toggle_switch: ^0.1.2" to clipboard
toggle_switch: ^0.1.2 copied to clipboard

outdated

Toggle Switch - A simple toggle switch widget. It can be fully customized - width, colors, text, corner radius etc. It maintains selection state on scroll.

Toggle Switch #

A simple toggle switch widget. It can be fully customized - width, colors, text, corner radius etc. It maintains selection state on scroll.

Getting Started #

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

dependencies:
  ...
  flutter_sticky_header: "^0.1.2"

Import it:

import 'package:toggle_switch/toggle_switch.dart';

Usage #

Example 1:

import 'package:flutter/material.dart';

import 'package:toggle_switch/toggle_switch.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              ToggleSwitch(
                minWidth: 90.0,
                initialLabel: 2,
                activeBgColor: Colors.redAccent,
                activeTextColor: Colors.white,
                inactiveBgColor: Colors.grey,
                inactiveTextColor: Colors.grey[900],
                labels: ['America', 'Canada', 'Mexico'],
                onToggle: (index) {
                  print('switched to: $index');
                },
              )
            ],
          ),
        ),
      ),
    );
  }
}

Example 1

Example 2:

import 'package:flutter/material.dart';

import 'package:toggle_switch/toggle_switch.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              ToggleSwitch(
                cornerRadius: 20,
                activeBgColor: Colors.green,
                activeTextColor: Colors.white,
                inactiveBgColor: Colors.grey,
                inactiveTextColor: Colors.white,
                labels: ['YES', 'NO'],
              ),
            ],
          ),
        ),
      ),
    );
  }
}

Example 2

Credits #

Eugene

1232
likes
0
pub points
99%
popularity

Publisher

verified publisherpramod.dev

Toggle Switch - A simple toggle switch widget. It can be fully customized - width, colors, text, corner radius etc. It maintains selection state on scroll.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on toggle_switch