Skip to content
This repository has been archived by the owner on Jan 19, 2023. It is now read-only.

Fixes #14 and #26 and #38 #35

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 25 additions & 16 deletions lib/fab_circular_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class FabCircularMenu extends StatefulWidget {
}

class FabCircularMenuState extends State<FabCircularMenu>
with SingleTickerProviderStateMixin {
with SingleTickerProviderStateMixin, WidgetsBindingObserver {
late double _screenWidth;
late double _screenHeight;
late double _marginH;
Expand Down Expand Up @@ -85,6 +85,7 @@ class FabCircularMenuState extends State<FabCircularMenu>
@override
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);

_animationController =
AnimationController(duration: widget.animationDuration, vsync: this);
Expand All @@ -111,9 +112,18 @@ class FabCircularMenuState extends State<FabCircularMenu>
@override
void dispose() {
_animationController.dispose();
WidgetsBinding.instance.removeObserver(this);
super.dispose();
}

@override
void didChangeMetrics() {
_calculateProps();
if (isOpen) {
close();
}
}

@override
void didChangeDependencies() {
super.didChangeDependencies();
Expand All @@ -131,29 +141,28 @@ class FabCircularMenuState extends State<FabCircularMenu>
return Container(
margin: widget.fabMargin,
// Removes the default FAB margin
transform: Matrix4.translationValues(16.0, 16.0, 0.0),
transform: Matrix4.translationValues(
16.0 * _directionX,
16.0 * _directionY,
0.0,
),
child: Stack(
alignment: widget.alignment,
children: <Widget>[
// Ring
Transform(
transform: Matrix4.translationValues(
_translationX,
_translationY,
0.0,
)..scale(_scaleAnimation.value),
alignment: FractionalOffset.center,
child: OverflowBox(
maxWidth: _ringDiameter,
maxHeight: _ringDiameter,
OverflowBox(
maxWidth: _ringDiameter,
maxHeight: _ringDiameter,
child: Transform(
transform:
Matrix4.translationValues(_translationX, _translationY, 0.0)
..scale(_scaleAnimation.value),
alignment: FractionalOffset.center,
child: Container(
width: _ringDiameter,
height: _ringDiameter,
child: CustomPaint(
painter: _RingPainter(
width: _ringWidth,
color: _ringColor,
),
painter: _RingPainter(width: _ringWidth, color: _ringColor),
child: _scaleAnimation.value == 1.0
? Transform.rotate(
angle: (2 * pi) *
Expand Down