pushable_button 0.0.4 pushable_button: ^0.0.4 copied to clipboard
A 3D pushable button. Ideal for important CTAs in the app.
import 'package:flutter/material.dart';
import 'package:pushable_button/pushable_button.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
debugShowCheckedModeBanner: false,
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
String _selection = 'none';
@override
Widget build(BuildContext context) {
const textStyle = TextStyle(
color: Colors.white,
fontSize: 24,
fontWeight: FontWeight.bold,
);
final shadow = BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 5,
blurRadius: 7,
offset: const Offset(0, 2),
);
return Scaffold(
body: Center(
child: Padding(
padding: const EdgeInsets.all(24.0),
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
PushableButton(
height: 60,
elevation: 8,
hslColor: const HSLColor.fromAHSL(1.0, 356, 1.0, 0.43),
shadow: shadow,
onPressed: () => setState(() => _selection = '1'),
child: const Text('PUSH ME 😎', style: textStyle),
),
const SizedBox(height: 32),
PushableButton(
height: 60,
elevation: 8,
hslColor: const HSLColor.fromAHSL(1.0, 120, 1.0, 0.37),
shadow: shadow,
onPressed: () => setState(() => _selection = '2'),
child: const Text('ENROLL NOW', style: textStyle),
),
const SizedBox(height: 32),
PushableButton(
height: 60,
elevation: 8,
hslColor: const HSLColor.fromAHSL(1.0, 195, 1.0, 0.43),
shadow: shadow,
onPressed: () => setState(() => _selection = '3'),
child: const Text('ADD TO BASKET', style: textStyle),
),
const SizedBox(height: 32),
Text(
'Pushed: $_selection',
style: textStyle.copyWith(color: Colors.black),
),
],
),
),
),
);
}
}