slider_switch 0.0.14 copy "slider_switch: ^0.0.14" to clipboard
slider_switch: ^0.0.14 copied to clipboard

An small and fully customizable toggleable slider switch for flutter.

example/main.dart

import 'package:flutter/material.dart';
import 'package:slider_switch/slider_switch.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                SliderSwitch(
                  isEnabled: false, // disable the button
                  // initialStatus: true,
                  // width: 50.0,
                  // lenght: 120.0,
                  // orientation: Axis.horizontal,
                  statusColorOpacity: 0.7,
                  onChanged: (bool value) => print("new listen value $value"),
                  // statusOnIconOffset: Offset(0.0, 0.0), // offset the position of the status on icon
                  // statusOffIconOffset: Offset(0.0, 0.0), // offset the position of the status off icon
                ),
                SliderSwitch(
                  // initialStatus: true, // default: false (false|true)
                  // width: 50.0,
                  // lenght: 120.0,
                  // orientation: Axis.horizontal, // default: Axis.vertical (Axis.vertical|Axis.horizontal)
                  statusColorOpacity: 0.7, // default 0.5
                  onChanged: (bool value) => print("new speaking value $value"),
                  statusOnIcon:
                      Icons.record_voice_over, // default: Icons.volume_up
                  statusOffIcon:
                      Icons.voice_over_off, // default: Icons.volume_off
                  statusOnColor: Colors.red, // default: Color.green
                  statusOnIconOffset: Offset(-5.0, 0.0),
                ),
              ],
            ),
            SliderSwitch(
              // status: true,
              // width: 50.0,
              // lenght: 120.0,
              orientation: Axis.horizontal,
              statusColorOpacity: 0.7,
              onChanged: (bool value) => print("new listen value $value"),
            ),
            SliderSwitch(
              // initialStatus: true, // default: false (false|true)
              // width: 50.0,
              // lenght: 120.0,
              orientation: Axis
                  .horizontal, // default: Axis.vertical (Axis.vertical|Axis.horizontal)
              statusColorOpacity: 0.7, // default 0.5
              onChanged: (bool value) => print("new speaking value $value"),
              statusOnIcon: Icons.record_voice_over, // default: Icons.volume_up
              statusOffIcon: Icons.voice_over_off, // default: Icons.volume_off
              statusOnColor: Colors.red, // default: Color.green
            ),
          ],
        ),
      ),
    );
  }
}
8
likes
140
pub points
45%
popularity

Publisher

verified publishersmallflutterpackages.blogspot.com

An small and fully customizable toggleable slider switch for flutter.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on slider_switch