-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfloatingactionbar.dart
97 lines (87 loc) · 2.39 KB
/
floatingactionbar.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import 'package:flutter/material.dart';
class FloatingActionBarAnimation extends StatefulWidget {
const FloatingActionBarAnimation({super.key});
@override
State<FloatingActionBarAnimation> createState() =>
_FloatingActionBarAnimationState();
}
class _FloatingActionBarAnimationState extends State<FloatingActionBarAnimation>
with TickerProviderStateMixin {
int _counter = 0;
late AnimationController _controller;
late Animation<double> _myAnimtion;
void floatingAction() {
if (_controller.isCompleted) {
_controller.reverse();
} else {
_controller.forward();
}
_incrementCounter();
}
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override
void initState() {
super.initState();
_controller = AnimationController(
vsync: this, duration: const Duration(milliseconds: 200));
_myAnimtion = CurvedAnimation(parent: _controller, curve: Curves.linear);
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Floating Action Bar"),
),
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,
),
],
),
),
bottomNavigationBar: BottomAppBar(
shape: const CircularNotchedRectangle(),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
IconButton(
icon: const Icon(Icons.menu),
onPressed: () {},
),
IconButton(
icon: const Icon(Icons.search),
onPressed: () {},
),
],
),
),
extendBody: true,
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
floatingActionButton: FloatingActionButton(
onPressed: floatingAction,
tooltip: 'Increment',
child: AnimatedIcon(
icon: AnimatedIcons.add_event,
progress: _myAnimtion,
),
),
);
}
}