bouncy_switch 1.0.2
bouncy_switch: ^1.0.2 copied to clipboard
A lightweight bouncy animated toggle switch for Flutter.
import 'package:flutter/material.dart';
import 'package:bouncy_switch/bouncy_switch.dart';
void main() => runApp(const MyApp());
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
bool enabled = false;
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Bouncy Switch')),
body: Center(
child: BouncySwitch(
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.2),
blurRadius: 4,
offset: const Offset(0, 2),
),
],
height: 24,
width: 40,
activeColor: Colors.deepPurpleAccent[400]!,
inactiveColor: Colors.grey[400]!,
value: enabled,
onChanged: (v) => setState(() => enabled = v),
),
),
),
);
}
}