fancy_fab_widget 0.0.1 fancy_fab_widget: ^0.0.1 copied to clipboard
An animated Floating Action Button toggle with animation.
import 'package:flutter/material.dart';
import 'package:fancy_fab/fancy_fab_widget.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
_incrementCounter() {
setState(() {
_counter++;
});
}
_decrementCounter() {
setState(() {
_counter = _counter - 1;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('This is the current number:'),
Text(
'$_counter',
style: Theme.of(context).textTheme.headline4,
),
],
),
),
floatingActionButton: FancyFabWidget(
tooltip: 'foo',
actions: [
FancyFabAction(
icon: Icons.add,
label: 'Add',
onPressed: _incrementCounter,
),
FancyFabAction(
icon: Icons.remove,
label: 'Remove',
onPressed: _decrementCounter,
color: Colors.red,
),
],
),
);
}
}