Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
0c24a4db
Unverified
Commit
0c24a4db
authored
Aug 24, 2022
by
Taha Tesser
Committed by
GitHub
Aug 24, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix `floatingActionButtonAnimator` not being updated (#110067)
parent
15b136d4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
4 deletions
+73
-4
scaffold.dart
packages/flutter/lib/src/material/scaffold.dart
+4
-4
floating_action_button_location_test.dart
...r/test/material/floating_action_button_location_test.dart
+69
-0
No files found.
packages/flutter/lib/src/material/scaffold.dart
View file @
0c24a4db
...
...
@@ -1305,15 +1305,15 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr
@override
void
didUpdateWidget
(
_FloatingActionButtonTransition
oldWidget
)
{
super
.
didUpdateWidget
(
oldWidget
);
if
(
oldWidget
.
fabMotionAnimator
!=
widget
.
fabMotionAnimator
||
oldWidget
.
fabMoveAnimation
!=
widget
.
fabMoveAnimation
)
{
// Get the right scale and rotation animations to use for this widget.
_updateAnimations
();
}
final
bool
oldChildIsNull
=
oldWidget
.
child
==
null
;
final
bool
newChildIsNull
=
widget
.
child
==
null
;
if
(
oldChildIsNull
==
newChildIsNull
&&
oldWidget
.
child
?.
key
==
widget
.
child
?.
key
)
{
return
;
}
if
(
oldWidget
.
fabMotionAnimator
!=
widget
.
fabMotionAnimator
||
oldWidget
.
fabMoveAnimation
!=
widget
.
fabMoveAnimation
)
{
// Get the right scale and rotation animations to use for this widget.
_updateAnimations
();
}
if
(
_previousController
.
status
==
AnimationStatus
.
dismissed
)
{
final
double
currentValue
=
widget
.
currentController
.
value
;
if
(
currentValue
==
0.0
||
oldWidget
.
child
==
null
)
{
...
...
packages/flutter/test/material/floating_action_button_location_test.dart
View file @
0c24a4db
...
...
@@ -607,6 +607,58 @@ void main() {
expect
(
tester
.
binding
.
transientCallbackCount
,
0
);
});
testWidgets
(
'Animator can be updated'
,
(
WidgetTester
tester
)
async
{
FloatingActionButtonAnimator
fabAnimator
=
FloatingActionButtonAnimator
.
scaling
;
FloatingActionButtonLocation
fabLocation
=
FloatingActionButtonLocation
.
startFloat
;
final
Duration
animationDuration
=
kFloatingActionButtonSegue
*
2
;
await
tester
.
pumpWidget
(
_singleFabScaffold
(
fabLocation
,
animator:
fabAnimator
,
));
expect
(
find
.
byType
(
FloatingActionButton
),
findsOneWidget
);
expect
(
tester
.
binding
.
transientCallbackCount
,
0
);
expect
(
tester
.
getCenter
(
find
.
byType
(
FloatingActionButton
)).
dx
,
44.0
);
fabLocation
=
FloatingActionButtonLocation
.
endFloat
;
await
tester
.
pumpWidget
(
_singleFabScaffold
(
fabLocation
,
animator:
fabAnimator
,
));
expect
(
tester
.
getTopLeft
(
find
.
byType
(
FloatingActionButton
)).
dx
,
lessThan
(
16.0
));
await
tester
.
pump
(
animationDuration
*
0.25
);
expect
(
tester
.
getTopLeft
(
find
.
byType
(
FloatingActionButton
)).
dx
,
greaterThan
(
16
));
await
tester
.
pump
(
animationDuration
*
0.25
);
expect
(
tester
.
getCenter
(
find
.
byType
(
FloatingActionButton
)).
dx
,
756.0
);
expect
(
tester
.
getTopRight
(
find
.
byType
(
FloatingActionButton
)).
dx
,
lessThan
(
800
-
16
));
await
tester
.
pump
(
animationDuration
*
0.25
);
expect
(
tester
.
getTopRight
(
find
.
byType
(
FloatingActionButton
)).
dx
,
lessThan
(
800
-
16
));
await
tester
.
pump
(
animationDuration
*
0.25
);
expect
(
tester
.
getTopRight
(
find
.
byType
(
FloatingActionButton
)).
dx
,
equals
(
800
-
16
));
fabLocation
=
FloatingActionButtonLocation
.
startFloat
;
fabAnimator
=
_NoScalingFabAnimator
();
await
tester
.
pumpWidget
(
_singleFabScaffold
(
fabLocation
,
animator:
fabAnimator
,
));
await
tester
.
pump
(
animationDuration
*
0.25
);
expect
(
tester
.
getCenter
(
find
.
byType
(
FloatingActionButton
)).
dx
,
756.0
);
expect
(
tester
.
getTopRight
(
find
.
byType
(
FloatingActionButton
)).
dx
,
equals
(
800
-
16
));
await
tester
.
pump
(
animationDuration
*
0.25
);
expect
(
tester
.
getCenter
(
find
.
byType
(
FloatingActionButton
)).
dx
,
44.0
);
expect
(
tester
.
getTopLeft
(
find
.
byType
(
FloatingActionButton
)).
dx
,
lessThan
(
16.0
));
});
});
group
(
'Locations account for safe interactive areas'
,
()
{
...
...
@@ -1717,3 +1769,20 @@ class _LinearMovementFabAnimator extends FloatingActionButtonAnimator {
return
const
AlwaysStoppedAnimation
<
double
>(
1.0
);
}
}
class
_NoScalingFabAnimator
extends
FloatingActionButtonAnimator
{
@override
Offset
getOffset
({
required
Offset
begin
,
required
Offset
end
,
required
double
progress
})
{
return
progress
<
0.5
?
begin
:
end
;
}
@override
Animation
<
double
>
getScaleAnimation
({
required
Animation
<
double
>
parent
})
{
return
const
AlwaysStoppedAnimation
<
double
>(
1.0
);
}
@override
Animation
<
double
>
getRotationAnimation
({
required
Animation
<
double
>
parent
})
{
return
const
AlwaysStoppedAnimation
<
double
>(
1.0
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment