dh_switch 1.0.2 copy "dh_switch: ^1.0.2" to clipboard
dh_switch: ^1.0.2 copied to clipboard

A Simple Switch package.

example/lib/main.dart

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

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'DHSwitch',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: SwitchPage(title: 'DHSwitch Demo'),
    );
  }
}

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

  final String title;

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

class _SwitchPageState extends State<SwitchPage> {
  bool value = false;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(title: Text(widget.title)),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.start,
            children: <Widget>[
              SizedBox(height: 80),
              Text("BorderStyle.solid"),
              DHSwitch(
                  value: value,
                  activeTrackColor: Colors.lightBlueAccent,
                  inactiveTrackColor: Colors.lightBlue,
                  borderColor: Colors.redAccent,
                  switchSize:
                      SwitchSize(width: 44.0, height: 24.0, borderWidth: 2.0),
                  onChanged: (value) {
                    setState(() => this.value = value);
                  },
                  borderStyle: BorderStyle.solid),
              SizedBox(height: 30),
              Text("BorderStyle.none"),
              DHSwitch(
                  value: value,
                  activeTrackColor: Colors.lightGreenAccent,
                  inactiveTrackColor: Colors.lightGreen,
                  borderColor: Colors.yellowAccent,
                  onChanged: (value) {
                    setState(() => this.value = value);
                  },
                  borderStyle: BorderStyle.none)
            ],
          ),
        ));
  }
}
0
likes
150
points
30
downloads

Publisher

unverified uploader

Weekly Downloads

A Simple Switch package.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on dh_switch