apptomate_custom_toggle_button 0.0.2
apptomate_custom_toggle_button: ^0.0.2 copied to clipboard
A customizable toggle button widget with smooth animations and flexible styling options.
example/lib/main.dart
import 'package:apptomate_custom_toggle_button/apptomate_custom_toggle_button.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override
_CustomToggleButtonExampleState createState() =>
_CustomToggleButtonExampleState();
}
class _CustomToggleButtonExampleState extends State<MyHomePage> {
bool isToggled = false;
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Center(
child: CustomToggleButton(
value: isToggled,
onChanged: (newValue) {
setState(() {
isToggled = newValue;
});
},
activeText: "ON",
inactiveText: "OFF",
activeColor: Colors.green,
inactiveColor: Colors.red,
),
),
),
);
}
}