s_toggle 3.0.0 copy "s_toggle: ^3.0.0" to clipboard
s_toggle: ^3.0.0 copied to clipboard

A customizable animated switch widget with smooth elastic animations, bounce effects, and flexible state management.

example/lib/main.dart

import 'package:s_toggle/s_toggle.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 's_toggle Example',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key});

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  bool _toggleValue = false;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('s_toggle Example'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            const Text(
              'Toggle the switch:',
            ),
            const SizedBox(height: 20),
            SToggle(
              size: 80.0,
              onColor: Colors.green,
              offColor: Colors.red,
              value: _toggleValue,
              onChange: (value) {
                setState(() {
                  _toggleValue = value;
                });
              },
            ),
            const SizedBox(height: 20),
            Text(
              'Toggle is ${_toggleValue ? 'ON' : 'OFF'}',
              style: Theme.of(context).textTheme.headlineSmall,
            ),
          ],
        ),
      ),
    );
  }
}
0
likes
160
points
18
downloads

Publisher

unverified uploader

Weekly Downloads

A customizable animated switch widget with smooth elastic animations, bounce effects, and flexible state management.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, s_packages

More

Packages that depend on s_toggle