@@ -265,7 +265,7 @@ void main() {
265
265
);
266
266
267
267
// The label animates downwards from it's initial position
268
- // above the input text. The animation's duration is 200ms .
268
+ // above the input text. The animation's duration is 167ms .
269
269
{
270
270
await tester.pump (const Duration (milliseconds: 50 ));
271
271
final double labelY50ms = tester.getTopLeft (find.text ('label' )).dy;
@@ -296,7 +296,7 @@ void main() {
296
296
);
297
297
298
298
// The label animates upwards from it's initial position
299
- // above the input text. The animation's duration is 200ms .
299
+ // above the input text. The animation's duration is 167ms .
300
300
await tester.pump (const Duration (milliseconds: 50 ));
301
301
final double labelY50ms = tester.getTopLeft (find.text ('label' )).dy;
302
302
expect (labelY50ms, inExclusiveRange (12.0 , 28.0 ));
@@ -563,7 +563,7 @@ void main() {
563
563
);
564
564
565
565
// The label animates downwards from it's initial position
566
- // above the input text. The animation's duration is 200ms .
566
+ // above the input text. The animation's duration is 167ms .
567
567
await tester.pump (const Duration (milliseconds: 50 ));
568
568
final double labelY50ms = tester.getTopLeft (find.byKey (key)).dy;
569
569
expect (labelY50ms, inExclusiveRange (12.0 , 20.0 ));
@@ -604,7 +604,7 @@ void main() {
604
604
);
605
605
606
606
// The label animates upwards from it's initial position
607
- // above the input text. The animation's duration is 200ms .
607
+ // above the input text. The animation's duration is 167ms .
608
608
{
609
609
await tester.pump (const Duration (milliseconds: 50 ));
610
610
final double labelY50ms = tester.getTopLeft (find.byKey (key)).dy;
@@ -720,6 +720,55 @@ void main() {
720
720
721
721
});
722
722
723
+ testWidgets ('InputDecorator floating label animation duration and curve' , (WidgetTester tester) async {
724
+ Future <void > pumpInputDecorator ({
725
+ required bool isFocused,
726
+ }) async {
727
+ return tester.pumpWidget (
728
+ buildInputDecorator (
729
+ isEmpty: true ,
730
+ isFocused: isFocused,
731
+ decoration: const InputDecoration (
732
+ labelText: 'label' ,
733
+ floatingLabelBehavior: FloatingLabelBehavior .auto,
734
+ ),
735
+ ),
736
+ );
737
+ }
738
+ await pumpInputDecorator (isFocused: false );
739
+ expect (tester.getTopLeft (find.text ('label' )).dy, 20.0 );
740
+
741
+ // The label animates upwards and scales down.
742
+ // The animation duration is 167ms and the curve is fastOutSlowIn.
743
+ await pumpInputDecorator (isFocused: true );
744
+ await tester.pump (const Duration (milliseconds: 42 ));
745
+ expect (tester.getTopLeft (find.text ('label' )).dy, closeTo (18.06 , 0.5 ));
746
+ await tester.pump (const Duration (milliseconds: 42 ));
747
+ expect (tester.getTopLeft (find.text ('label' )).dy, closeTo (13.78 , 0.5 ));
748
+ await tester.pump (const Duration (milliseconds: 42 ));
749
+ expect (tester.getTopLeft (find.text ('label' )).dy, closeTo (12.31 , 0.5 ));
750
+ await tester.pump (const Duration (milliseconds: 41 ));
751
+ expect (tester.getTopLeft (find.text ('label' )).dy, 12.0 );
752
+
753
+ // If the animation changes direction without first reaching the
754
+ // AnimationStatus.completed or AnimationStatus.dismissed status,
755
+ // the CurvedAnimation stays on the same curve in the opposite direction.
756
+ // The pumpAndSettle is used to prevent this behavior.
757
+ await tester.pumpAndSettle ();
758
+
759
+ // The label animates downwards and scales up.
760
+ // The animation duration is 167ms and the curve is fastOutSlowIn.
761
+ await pumpInputDecorator (isFocused: false );
762
+ await tester.pump (const Duration (milliseconds: 42 ));
763
+ expect (tester.getTopLeft (find.text ('label' )).dy, closeTo (13.94 , 0.5 ));
764
+ await tester.pump (const Duration (milliseconds: 42 ));
765
+ expect (tester.getTopLeft (find.text ('label' )).dy, closeTo (18.22 , 0.5 ));
766
+ await tester.pump (const Duration (milliseconds: 42 ));
767
+ expect (tester.getTopLeft (find.text ('label' )).dy, closeTo (19.69 , 0.5 ));
768
+ await tester.pump (const Duration (milliseconds: 41 ));
769
+ expect (tester.getTopLeft (find.text ('label' )).dy, 20.0 );
770
+ });
771
+
723
772
group ('alignLabelWithHint' , () {
724
773
group ('expands false' , () {
725
774
testWidgets ('multiline TextField no-strut' , (WidgetTester tester) async {
@@ -1013,7 +1062,7 @@ void main() {
1013
1062
);
1014
1063
1015
1064
// The hint's opacity animates from 0.0 to 1.0.
1016
- // The animation's duration is 200ms .
1065
+ // The animation's duration is 167ms .
1017
1066
{
1018
1067
await tester.pump (const Duration (milliseconds: 50 ));
1019
1068
final double hintOpacity50ms = getOpacity (tester, 'hint' );
@@ -1047,7 +1096,7 @@ void main() {
1047
1096
);
1048
1097
1049
1098
// The hint's opacity animates from 1.0 to 0.0.
1050
- // The animation's duration is 200ms .
1099
+ // The animation's duration is 167ms .
1051
1100
{
1052
1101
await tester.pump (const Duration (milliseconds: 50 ));
1053
1102
final double hintOpacity50ms = getOpacity (tester, 'hint' );
@@ -1968,7 +2017,7 @@ void main() {
1968
2017
);
1969
2018
1970
2019
// The hint's opacity animates from 0.0 to 1.0.
1971
- // The animation's duration is 200ms .
2020
+ // The animation's duration is 167ms .
1972
2021
{
1973
2022
await tester.pump (const Duration (milliseconds: 50 ));
1974
2023
final double hintOpacity50ms = getOpacity (tester, 'hint' );
@@ -2003,7 +2052,7 @@ void main() {
2003
2052
);
2004
2053
2005
2054
// The hint's opacity animates from 1.0 to 0.0.
2006
- // The animation's duration is 200ms .
2055
+ // The animation's duration is 167ms .
2007
2056
{
2008
2057
await tester.pump (const Duration (milliseconds: 50 ));
2009
2058
final double hintOpacity50ms = getOpacity (tester, 'hint' );
@@ -2065,7 +2114,7 @@ void main() {
2065
2114
);
2066
2115
2067
2116
// The hint's opacity animates from 0.0 to 1.0.
2068
- // The animation's duration is 200ms .
2117
+ // The animation's duration is 167ms .
2069
2118
{
2070
2119
await tester.pump (const Duration (milliseconds: 50 ));
2071
2120
final double hintOpacity50ms = getOpacity (tester, 'hint' );
@@ -2100,7 +2149,7 @@ void main() {
2100
2149
);
2101
2150
2102
2151
// The hint's opacity animates from 1.0 to 0.0.
2103
- // The animation's duration is 200ms .
2152
+ // The animation's duration is 167ms .
2104
2153
{
2105
2154
await tester.pump (const Duration (milliseconds: 50 ));
2106
2155
final double hintOpacity50ms = getOpacity (tester, 'hint' );
@@ -4414,17 +4463,17 @@ void main() {
4414
4463
4415
4464
await pumpDecorator (hovering: true , filled: false );
4416
4465
expect (getBorderColor (tester), equals (enabledBorderColor));
4417
- await tester.pump (const Duration (milliseconds: 200 ));
4466
+ await tester.pump (const Duration (milliseconds: 167 ));
4418
4467
expect (getBorderColor (tester), equals (blendedHoverColor));
4419
4468
4420
4469
await pumpDecorator (hovering: false , filled: false );
4421
4470
expect (getBorderColor (tester), equals (blendedHoverColor));
4422
- await tester.pump (const Duration (milliseconds: 200 ));
4471
+ await tester.pump (const Duration (milliseconds: 167 ));
4423
4472
expect (getBorderColor (tester), equals (enabledBorderColor));
4424
4473
4425
4474
await pumpDecorator (hovering: false , filled: false , enabled: false );
4426
4475
expect (getBorderColor (tester), equals (enabledBorderColor));
4427
- await tester.pump (const Duration (milliseconds: 200 ));
4476
+ await tester.pump (const Duration (milliseconds: 167 ));
4428
4477
expect (getBorderColor (tester), equals (disabledColor));
4429
4478
4430
4479
await pumpDecorator (hovering: true , filled: false , enabled: false );
@@ -4468,17 +4517,17 @@ void main() {
4468
4517
4469
4518
await pumpDecorator (focused: true , filled: false );
4470
4519
expect (getBorderColor (tester), equals (enabledBorderColor));
4471
- await tester.pump (const Duration (milliseconds: 200 ));
4520
+ await tester.pump (const Duration (milliseconds: 167 ));
4472
4521
expect (getBorderColor (tester), equals (focusColor));
4473
4522
4474
4523
await pumpDecorator (focused: false , filled: false );
4475
4524
expect (getBorderColor (tester), equals (focusColor));
4476
- await tester.pump (const Duration (milliseconds: 200 ));
4525
+ await tester.pump (const Duration (milliseconds: 167 ));
4477
4526
expect (getBorderColor (tester), equals (enabledBorderColor));
4478
4527
4479
4528
await pumpDecorator (focused: false , filled: false , enabled: false );
4480
4529
expect (getBorderColor (tester), equals (enabledBorderColor));
4481
- await tester.pump (const Duration (milliseconds: 200 ));
4530
+ await tester.pump (const Duration (milliseconds: 167 ));
4482
4531
expect (getBorderColor (tester), equals (disabledColor));
4483
4532
4484
4533
await pumpDecorator (focused: true , filled: false , enabled: false );
@@ -5562,8 +5611,8 @@ void main() {
5562
5611
5563
5612
// Click for Focus.
5564
5613
await tester.tap (find.byType (TextField ));
5565
- // Default animation duration is 200 millisecond .
5566
- await tester.pumpFrames (target, const Duration (milliseconds: 100 ));
5614
+ // Default animation duration is 167ms .
5615
+ await tester.pumpFrames (target, const Duration (milliseconds: 80 ));
5567
5616
5568
5617
expect (getLabelRect (tester).width, greaterThan (labelWidth));
5569
5618
expect (getLabelRect (tester).width, lessThanOrEqualTo (floatedLabelWidth));
0 commit comments