@@ -266,7 +266,7 @@ void main() {
266
266
);
267
267
268
268
// The label animates downwards from it's initial position
269
- // above the input text. The animation's duration is 200ms .
269
+ // above the input text. The animation's duration is 167ms .
270
270
{
271
271
await tester.pump (const Duration (milliseconds: 50 ));
272
272
final double labelY50ms = tester.getTopLeft (find.text ('label' )).dy;
@@ -297,7 +297,7 @@ void main() {
297
297
);
298
298
299
299
// The label animates upwards from it's initial position
300
- // above the input text. The animation's duration is 200ms .
300
+ // above the input text. The animation's duration is 167ms .
301
301
await tester.pump (const Duration (milliseconds: 50 ));
302
302
final double labelY50ms = tester.getTopLeft (find.text ('label' )).dy;
303
303
expect (labelY50ms, inExclusiveRange (12.0 , 28.0 ));
@@ -564,7 +564,7 @@ void main() {
564
564
);
565
565
566
566
// The label animates downwards from it's initial position
567
- // above the input text. The animation's duration is 200ms .
567
+ // above the input text. The animation's duration is 167ms .
568
568
await tester.pump (const Duration (milliseconds: 50 ));
569
569
final double labelY50ms = tester.getTopLeft (find.byKey (key)).dy;
570
570
expect (labelY50ms, inExclusiveRange (12.0 , 20.0 ));
@@ -605,7 +605,7 @@ void main() {
605
605
);
606
606
607
607
// The label animates upwards from it's initial position
608
- // above the input text. The animation's duration is 200ms .
608
+ // above the input text. The animation's duration is 167ms .
609
609
{
610
610
await tester.pump (const Duration (milliseconds: 50 ));
611
611
final double labelY50ms = tester.getTopLeft (find.byKey (key)).dy;
@@ -721,6 +721,55 @@ void main() {
721
721
722
722
});
723
723
724
+ testWidgets ('InputDecorator floating label animation duration and curve' , (WidgetTester tester) async {
725
+ Future <void > pumpInputDecorator ({
726
+ required bool isFocused,
727
+ }) async {
728
+ return tester.pumpWidget (
729
+ buildInputDecorator (
730
+ isEmpty: true ,
731
+ isFocused: isFocused,
732
+ decoration: const InputDecoration (
733
+ labelText: 'label' ,
734
+ floatingLabelBehavior: FloatingLabelBehavior .auto,
735
+ ),
736
+ ),
737
+ );
738
+ }
739
+ await pumpInputDecorator (isFocused: false );
740
+ expect (tester.getTopLeft (find.text ('label' )).dy, 20.0 );
741
+
742
+ // The label animates upwards and scales down.
743
+ // The animation duration is 167ms and the curve is fastOutSlowIn.
744
+ await pumpInputDecorator (isFocused: true );
745
+ await tester.pump (const Duration (milliseconds: 42 ));
746
+ expect (tester.getTopLeft (find.text ('label' )).dy, closeTo (18.06 , 0.5 ));
747
+ await tester.pump (const Duration (milliseconds: 42 ));
748
+ expect (tester.getTopLeft (find.text ('label' )).dy, closeTo (13.78 , 0.5 ));
749
+ await tester.pump (const Duration (milliseconds: 42 ));
750
+ expect (tester.getTopLeft (find.text ('label' )).dy, closeTo (12.31 , 0.5 ));
751
+ await tester.pump (const Duration (milliseconds: 41 ));
752
+ expect (tester.getTopLeft (find.text ('label' )).dy, 12.0 );
753
+
754
+ // If the animation changes direction without first reaching the
755
+ // AnimationStatus.completed or AnimationStatus.dismissed status,
756
+ // the CurvedAnimation stays on the same curve in the opposite direction.
757
+ // The pumpAndSettle is used to prevent this behavior.
758
+ await tester.pumpAndSettle ();
759
+
760
+ // The label animates downwards and scales up.
761
+ // The animation duration is 167ms and the curve is fastOutSlowIn.
762
+ await pumpInputDecorator (isFocused: false );
763
+ await tester.pump (const Duration (milliseconds: 42 ));
764
+ expect (tester.getTopLeft (find.text ('label' )).dy, closeTo (13.94 , 0.5 ));
765
+ await tester.pump (const Duration (milliseconds: 42 ));
766
+ expect (tester.getTopLeft (find.text ('label' )).dy, closeTo (18.22 , 0.5 ));
767
+ await tester.pump (const Duration (milliseconds: 42 ));
768
+ expect (tester.getTopLeft (find.text ('label' )).dy, closeTo (19.69 , 0.5 ));
769
+ await tester.pump (const Duration (milliseconds: 41 ));
770
+ expect (tester.getTopLeft (find.text ('label' )).dy, 20.0 );
771
+ });
772
+
724
773
group ('alignLabelWithHint' , () {
725
774
group ('expands false' , () {
726
775
testWidgets ('multiline TextField no-strut' , (WidgetTester tester) async {
@@ -1014,7 +1063,7 @@ void main() {
1014
1063
);
1015
1064
1016
1065
// The hint's opacity animates from 0.0 to 1.0.
1017
- // The animation's duration is 200ms .
1066
+ // The animation's duration is 167ms .
1018
1067
{
1019
1068
await tester.pump (const Duration (milliseconds: 50 ));
1020
1069
final double hintOpacity50ms = getOpacity (tester, 'hint' );
@@ -1048,7 +1097,7 @@ void main() {
1048
1097
);
1049
1098
1050
1099
// The hint's opacity animates from 1.0 to 0.0.
1051
- // The animation's duration is 200ms .
1100
+ // The animation's duration is 167ms .
1052
1101
{
1053
1102
await tester.pump (const Duration (milliseconds: 50 ));
1054
1103
final double hintOpacity50ms = getOpacity (tester, 'hint' );
@@ -1969,7 +2018,7 @@ void main() {
1969
2018
);
1970
2019
1971
2020
// The hint's opacity animates from 0.0 to 1.0.
1972
- // The animation's duration is 200ms .
2021
+ // The animation's duration is 167ms .
1973
2022
{
1974
2023
await tester.pump (const Duration (milliseconds: 50 ));
1975
2024
final double hintOpacity50ms = getOpacity (tester, 'hint' );
@@ -2004,7 +2053,7 @@ void main() {
2004
2053
);
2005
2054
2006
2055
// The hint's opacity animates from 1.0 to 0.0.
2007
- // The animation's duration is 200ms .
2056
+ // The animation's duration is 167ms .
2008
2057
{
2009
2058
await tester.pump (const Duration (milliseconds: 50 ));
2010
2059
final double hintOpacity50ms = getOpacity (tester, 'hint' );
@@ -2066,7 +2115,7 @@ void main() {
2066
2115
);
2067
2116
2068
2117
// The hint's opacity animates from 0.0 to 1.0.
2069
- // The animation's duration is 200ms .
2118
+ // The animation's duration is 167ms .
2070
2119
{
2071
2120
await tester.pump (const Duration (milliseconds: 50 ));
2072
2121
final double hintOpacity50ms = getOpacity (tester, 'hint' );
@@ -2101,7 +2150,7 @@ void main() {
2101
2150
);
2102
2151
2103
2152
// The hint's opacity animates from 1.0 to 0.0.
2104
- // The animation's duration is 200ms .
2153
+ // The animation's duration is 167ms .
2105
2154
{
2106
2155
await tester.pump (const Duration (milliseconds: 50 ));
2107
2156
final double hintOpacity50ms = getOpacity (tester, 'hint' );
@@ -4512,17 +4561,17 @@ void main() {
4512
4561
4513
4562
await pumpDecorator (hovering: true , filled: false );
4514
4563
expect (getBorderColor (tester), equals (enabledBorderColor));
4515
- await tester.pump (const Duration (milliseconds: 200 ));
4564
+ await tester.pump (const Duration (milliseconds: 167 ));
4516
4565
expect (getBorderColor (tester), equals (blendedHoverColor));
4517
4566
4518
4567
await pumpDecorator (hovering: false , filled: false );
4519
4568
expect (getBorderColor (tester), equals (blendedHoverColor));
4520
- await tester.pump (const Duration (milliseconds: 200 ));
4569
+ await tester.pump (const Duration (milliseconds: 167 ));
4521
4570
expect (getBorderColor (tester), equals (enabledBorderColor));
4522
4571
4523
4572
await pumpDecorator (hovering: false , filled: false , enabled: false );
4524
4573
expect (getBorderColor (tester), equals (enabledBorderColor));
4525
- await tester.pump (const Duration (milliseconds: 200 ));
4574
+ await tester.pump (const Duration (milliseconds: 167 ));
4526
4575
expect (getBorderColor (tester), equals (disabledColor));
4527
4576
4528
4577
await pumpDecorator (hovering: true , filled: false , enabled: false );
@@ -4566,17 +4615,17 @@ void main() {
4566
4615
4567
4616
await pumpDecorator (focused: true , filled: false );
4568
4617
expect (getBorderColor (tester), equals (enabledBorderColor));
4569
- await tester.pump (const Duration (milliseconds: 200 ));
4618
+ await tester.pump (const Duration (milliseconds: 167 ));
4570
4619
expect (getBorderColor (tester), equals (focusColor));
4571
4620
4572
4621
await pumpDecorator (focused: false , filled: false );
4573
4622
expect (getBorderColor (tester), equals (focusColor));
4574
- await tester.pump (const Duration (milliseconds: 200 ));
4623
+ await tester.pump (const Duration (milliseconds: 167 ));
4575
4624
expect (getBorderColor (tester), equals (enabledBorderColor));
4576
4625
4577
4626
await pumpDecorator (focused: false , filled: false , enabled: false );
4578
4627
expect (getBorderColor (tester), equals (enabledBorderColor));
4579
- await tester.pump (const Duration (milliseconds: 200 ));
4628
+ await tester.pump (const Duration (milliseconds: 167 ));
4580
4629
expect (getBorderColor (tester), equals (disabledColor));
4581
4630
4582
4631
await pumpDecorator (focused: true , filled: false , enabled: false );
@@ -5661,8 +5710,8 @@ void main() {
5661
5710
5662
5711
// Click for Focus.
5663
5712
await tester.tap (find.byType (TextField ));
5664
- // Default animation duration is 200 millisecond .
5665
- await tester.pumpFrames (target, const Duration (milliseconds: 100 ));
5713
+ // Default animation duration is 167ms .
5714
+ await tester.pumpFrames (target, const Duration (milliseconds: 80 ));
5666
5715
5667
5716
expect (getLabelRect (tester).width, greaterThan (labelWidth));
5668
5717
expect (getLabelRect (tester).width, lessThanOrEqualTo (floatedLabelWidth));
0 commit comments