flat_3d_button 1.0.2 flat_3d_button: ^1.0.2 copied to clipboard
A simple 3D flat button with click animation, flat 3d button contains 3 methods, a flat 3d button with any widget as it's child, text as it's child and also an icon as it's child
import 'package:flutter/material.dart';
import 'package:flat_3d_button/flat_3d_button.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flat 3D Button Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Flat 3D Button Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
void _decrementCounter() {
setState(() {
_counter--;
});
}
void _resetCounter() {
setState(() {
_counter = 0;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headline4,
),
const SizedBox(
height: 10,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Flat3dButton.icon(
color: Colors.red,
onPressed: _decrementCounter,
icon: Icons.remove,
),
const SizedBox(width: 10),
Flat3dButton.text(
onPressed: _resetCounter,
text: 'reset',
),
const SizedBox(width: 10),
Flat3dButton.icon(
color: Colors.green,
onPressed: _incrementCounter,
icon: Icons.add,
),
],
)
],
),
),
);
}
}