mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Don't animate fab in a new scaffold (#5015)
If the scaffold is new and has a floating action button, we skip the entrance animation for the fab. Fixes #4445
This commit is contained in:
parent
39e759212f
commit
ae80d43364
@ -43,7 +43,7 @@ class FloatingActionButton extends StatefulWidget {
|
||||
/// Most commonly used in the [Scaffold.floatingActionButton] field.
|
||||
const FloatingActionButton({
|
||||
Key key,
|
||||
this.child,
|
||||
@required this.child,
|
||||
this.tooltip,
|
||||
this.backgroundColor,
|
||||
this.elevation: 6,
|
||||
|
||||
@ -155,6 +155,11 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// If we start out with a child, have the child appear fully visible instead
|
||||
// of animating in.
|
||||
if (config.child != null)
|
||||
_currentController.value = 1.0;
|
||||
|
||||
_previousAnimation = new CurvedAnimation(
|
||||
parent: _previousController,
|
||||
curve: Curves.easeIn
|
||||
@ -165,7 +170,6 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr
|
||||
);
|
||||
|
||||
_previousController.addStatusListener(_handleAnimationStatusChanged);
|
||||
_currentController.forward();
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@ -40,4 +40,40 @@ void main() {
|
||||
bodyBox = tester.renderObject(find.byKey(bodyKey));
|
||||
expect(bodyBox.size, equals(new Size(800.0, 544.0)));
|
||||
});
|
||||
|
||||
testWidgets('Floating action animation', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(new Scaffold(
|
||||
floatingActionButton: new FloatingActionButton(
|
||||
key: new Key("one"),
|
||||
onPressed: null,
|
||||
child: new Text("1")
|
||||
)
|
||||
));
|
||||
|
||||
expect(tester.binding.transientCallbackCount, 0);
|
||||
|
||||
await tester.pumpWidget(new Scaffold(
|
||||
floatingActionButton: new FloatingActionButton(
|
||||
key: new Key("two"),
|
||||
onPressed: null,
|
||||
child: new Text("2")
|
||||
)
|
||||
));
|
||||
|
||||
expect(tester.binding.transientCallbackCount, greaterThan(0));
|
||||
await tester.pumpWidget(new Container());
|
||||
expect(tester.binding.transientCallbackCount, 0);
|
||||
await tester.pumpWidget(new Scaffold());
|
||||
expect(tester.binding.transientCallbackCount, 0);
|
||||
|
||||
await tester.pumpWidget(new Scaffold(
|
||||
floatingActionButton: new FloatingActionButton(
|
||||
key: new Key("one"),
|
||||
onPressed: null,
|
||||
child: new Text("1")
|
||||
)
|
||||
));
|
||||
|
||||
expect(tester.binding.transientCallbackCount, greaterThan(0));
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user