@@ -144,15 +144,6 @@ double getOpacity(WidgetTester tester, String textValue) {
144
144
return opacityWidget.opacity.value;
145
145
}
146
146
147
- double getStaticOpacity (WidgetTester tester, String textValue) {
148
- return tester.widget <Opacity >(
149
- find.ancestor (
150
- of: find.text (textValue),
151
- matching: find.byType (Opacity ),
152
- ).first,
153
- ).opacity;
154
- }
155
-
156
147
void main () {
157
148
testWidgets ('InputDecorator input/label text layout' , (WidgetTester tester) async {
158
149
// The label appears above the input text
@@ -972,7 +963,7 @@ void main() {
972
963
expect (tester.getBottomLeft (find.text ('text' )).dy, 44.0 );
973
964
expect (tester.getTopLeft (find.text ('label' )).dy, 20.0 );
974
965
expect (tester.getBottomLeft (find.text ('label' )).dy, 36.0 );
975
- expect (getStaticOpacity (tester, 'hint' ), 0.0 );
966
+ expect (getOpacity (tester, 'hint' ), 0.0 );
976
967
expect (getBorderBottom (tester), 56.0 );
977
968
expect (getBorderWeight (tester), 1.0 );
978
969
@@ -988,6 +979,17 @@ void main() {
988
979
),
989
980
);
990
981
982
+ // The hint's opacity animates from 0.0 to 1.0.
983
+ // The animation's duration is 200ms.
984
+ {
985
+ await tester.pump (const Duration (milliseconds: 50 ));
986
+ final double hintOpacity50ms = getOpacity (tester, 'hint' );
987
+ expect (hintOpacity50ms, inExclusiveRange (0.0 , 1.0 ));
988
+ await tester.pump (const Duration (milliseconds: 50 ));
989
+ final double hintOpacity100ms = getOpacity (tester, 'hint' );
990
+ expect (hintOpacity100ms, inExclusiveRange (hintOpacity50ms, 1.0 ));
991
+ }
992
+
991
993
await tester.pumpAndSettle ();
992
994
expect (tester.getSize (find.byType (InputDecorator )), const Size (800.0 , 56.0 ));
993
995
expect (tester.getTopLeft (find.text ('text' )).dy, 28.0 );
@@ -996,7 +998,7 @@ void main() {
996
998
expect (tester.getBottomLeft (find.text ('label' )).dy, 24.0 );
997
999
expect (tester.getTopLeft (find.text ('hint' )).dy, 28.0 );
998
1000
expect (tester.getBottomLeft (find.text ('hint' )).dy, 44.0 );
999
- expect (getStaticOpacity (tester, 'hint' ), 1.0 );
1001
+ expect (getOpacity (tester, 'hint' ), 1.0 );
1000
1002
expect (getBorderBottom (tester), 56.0 );
1001
1003
expect (getBorderWeight (tester), 2.0 );
1002
1004
@@ -1010,6 +1012,17 @@ void main() {
1010
1012
),
1011
1013
);
1012
1014
1015
+ // The hint's opacity animates from 1.0 to 0.0.
1016
+ // The animation's duration is 200ms.
1017
+ {
1018
+ await tester.pump (const Duration (milliseconds: 50 ));
1019
+ final double hintOpacity50ms = getOpacity (tester, 'hint' );
1020
+ expect (hintOpacity50ms, inExclusiveRange (0.0 , 1.0 ));
1021
+ await tester.pump (const Duration (milliseconds: 50 ));
1022
+ final double hintOpacity100ms = getOpacity (tester, 'hint' );
1023
+ expect (hintOpacity100ms, inExclusiveRange (0.0 , hintOpacity50ms));
1024
+ }
1025
+
1013
1026
await tester.pumpAndSettle ();
1014
1027
expect (tester.getSize (find.byType (InputDecorator )), const Size (800.0 , 56.0 ));
1015
1028
expect (tester.getTopLeft (find.text ('text' )).dy, 28.0 );
@@ -1018,7 +1031,7 @@ void main() {
1018
1031
expect (tester.getBottomLeft (find.text ('label' )).dy, 24.0 );
1019
1032
expect (tester.getTopLeft (find.text ('hint' )).dy, 28.0 );
1020
1033
expect (tester.getBottomLeft (find.text ('hint' )).dy, 44.0 );
1021
- expect (getStaticOpacity (tester, 'hint' ), 0.0 );
1034
+ expect (getOpacity (tester, 'hint' ), 0.0 );
1022
1035
expect (getBorderBottom (tester), 56.0 );
1023
1036
expect (getBorderWeight (tester), 2.0 );
1024
1037
});
@@ -1058,7 +1071,7 @@ void main() {
1058
1071
expect (tester.getBottomLeft (find.text ('text' )).dy, 40.0 );
1059
1072
expect (tester.getTopLeft (find.text ('label' )).dy, 16.0 );
1060
1073
expect (tester.getBottomLeft (find.text ('label' )).dy, 32.0 );
1061
- expect (getStaticOpacity (tester, 'hint' ), 0.0 );
1074
+ expect (getOpacity (tester, 'hint' ), 0.0 );
1062
1075
expect (getBorderBottom (tester), 48.0 );
1063
1076
expect (getBorderWeight (tester), 1.0 );
1064
1077
@@ -1080,7 +1093,7 @@ void main() {
1080
1093
expect (tester.getBottomLeft (find.text ('text' )).dy, 40.0 );
1081
1094
expect (tester.getTopLeft (find.text ('label' )).dy, 8.0 );
1082
1095
expect (tester.getBottomLeft (find.text ('label' )).dy, 20.0 );
1083
- expect (getStaticOpacity (tester, 'hint' ), 1.0 );
1096
+ expect (getOpacity (tester, 'hint' ), 1.0 );
1084
1097
expect (getBorderBottom (tester), 48.0 );
1085
1098
expect (getBorderWeight (tester), 2.0 );
1086
1099
});
@@ -1855,7 +1868,7 @@ void main() {
1855
1868
expect (tester.getBottomLeft (find.text ('text' )).dy, 40.0 );
1856
1869
expect (tester.getTopLeft (find.text ('label' )).dy, 16.0 );
1857
1870
expect (tester.getBottomLeft (find.text ('label' )).dy, 32.0 );
1858
- expect (getStaticOpacity (tester, 'hint' ), 0.0 );
1871
+ expect (getOpacity (tester, 'hint' ), 0.0 );
1859
1872
expect (getBorderBottom (tester), 48.0 );
1860
1873
expect (getBorderWeight (tester), 1.0 );
1861
1874
@@ -1872,6 +1885,17 @@ void main() {
1872
1885
),
1873
1886
);
1874
1887
1888
+ // The hint's opacity animates from 0.0 to 1.0.
1889
+ // The animation's duration is 200ms.
1890
+ {
1891
+ await tester.pump (const Duration (milliseconds: 50 ));
1892
+ final double hintOpacity50ms = getOpacity (tester, 'hint' );
1893
+ expect (hintOpacity50ms, inExclusiveRange (0.0 , 1.0 ));
1894
+ await tester.pump (const Duration (milliseconds: 50 ));
1895
+ final double hintOpacity100ms = getOpacity (tester, 'hint' );
1896
+ expect (hintOpacity100ms, inExclusiveRange (hintOpacity50ms, 1.0 ));
1897
+ }
1898
+
1875
1899
await tester.pumpAndSettle ();
1876
1900
expect (tester.getSize (find.byType (InputDecorator )), const Size (800.0 , 48.0 ));
1877
1901
expect (tester.getTopLeft (find.text ('text' )).dy, 24.0 );
@@ -1880,7 +1904,7 @@ void main() {
1880
1904
expect (tester.getBottomLeft (find.text ('label' )).dy, 24.0 );
1881
1905
expect (tester.getTopLeft (find.text ('hint' )).dy, 24.0 );
1882
1906
expect (tester.getBottomLeft (find.text ('hint' )).dy, 40.0 );
1883
- expect (getStaticOpacity (tester, 'hint' ), 1.0 );
1907
+ expect (getOpacity (tester, 'hint' ), 1.0 );
1884
1908
expect (getBorderBottom (tester), 48.0 );
1885
1909
expect (getBorderWeight (tester), 2.0 );
1886
1910
@@ -1895,6 +1919,17 @@ void main() {
1895
1919
),
1896
1920
);
1897
1921
1922
+ // The hint's opacity animates from 1.0 to 0.0.
1923
+ // The animation's duration is 200ms.
1924
+ {
1925
+ await tester.pump (const Duration (milliseconds: 50 ));
1926
+ final double hintOpacity50ms = getOpacity (tester, 'hint' );
1927
+ expect (hintOpacity50ms, inExclusiveRange (0.0 , 1.0 ));
1928
+ await tester.pump (const Duration (milliseconds: 50 ));
1929
+ final double hintOpacity100ms = getOpacity (tester, 'hint' );
1930
+ expect (hintOpacity100ms, inExclusiveRange (0.0 , hintOpacity50ms));
1931
+ }
1932
+
1898
1933
await tester.pumpAndSettle ();
1899
1934
expect (tester.getSize (find.byType (InputDecorator )), const Size (800.0 , 48.0 ));
1900
1935
expect (tester.getTopLeft (find.text ('text' )).dy, 24.0 );
@@ -1903,7 +1938,7 @@ void main() {
1903
1938
expect (tester.getBottomLeft (find.text ('label' )).dy, 24.0 );
1904
1939
expect (tester.getTopLeft (find.text ('hint' )).dy, 24.0 );
1905
1940
expect (tester.getBottomLeft (find.text ('hint' )).dy, 40.0 );
1906
- expect (getStaticOpacity (tester, 'hint' ), 0.0 );
1941
+ expect (getOpacity (tester, 'hint' ), 0.0 );
1907
1942
expect (getBorderBottom (tester), 48.0 );
1908
1943
expect (getBorderWeight (tester), 2.0 );
1909
1944
});
@@ -1927,7 +1962,7 @@ void main() {
1927
1962
expect (tester.getBottomLeft (find.text ('text' )).dy, 48.0 );
1928
1963
expect (tester.getTopLeft (find.text ('label' )).dy, 24.0 );
1929
1964
expect (tester.getBottomLeft (find.text ('label' )).dy, 40.0 );
1930
- expect (getStaticOpacity (tester, 'hint' ), 0.0 );
1965
+ expect (getOpacity (tester, 'hint' ), 0.0 );
1931
1966
expect (getBorderBottom (tester), 64.0 );
1932
1967
expect (getBorderWeight (tester), 1.0 );
1933
1968
@@ -1944,6 +1979,17 @@ void main() {
1944
1979
),
1945
1980
);
1946
1981
1982
+ // The hint's opacity animates from 0.0 to 1.0.
1983
+ // The animation's duration is 200ms.
1984
+ {
1985
+ await tester.pump (const Duration (milliseconds: 50 ));
1986
+ final double hintOpacity50ms = getOpacity (tester, 'hint' );
1987
+ expect (hintOpacity50ms, inExclusiveRange (0.0 , 1.0 ));
1988
+ await tester.pump (const Duration (milliseconds: 50 ));
1989
+ final double hintOpacity100ms = getOpacity (tester, 'hint' );
1990
+ expect (hintOpacity100ms, inExclusiveRange (hintOpacity50ms, 1.0 ));
1991
+ }
1992
+
1947
1993
await tester.pumpAndSettle ();
1948
1994
expect (tester.getSize (find.byType (InputDecorator )), const Size (800.0 , 64.0 ));
1949
1995
expect (tester.getTopLeft (find.text ('text' )).dy, 32.0 );
@@ -1952,7 +1998,7 @@ void main() {
1952
1998
expect (tester.getBottomLeft (find.text ('label' )).dy, 24.0 );
1953
1999
expect (tester.getTopLeft (find.text ('hint' )).dy, 32.0 );
1954
2000
expect (tester.getBottomLeft (find.text ('hint' )).dy, 48.0 );
1955
- expect (getStaticOpacity (tester, 'hint' ), 1.0 );
2001
+ expect (getOpacity (tester, 'hint' ), 1.0 );
1956
2002
expect (getBorderBottom (tester), 64.0 );
1957
2003
expect (getBorderWeight (tester), 2.0 );
1958
2004
@@ -1967,6 +2013,17 @@ void main() {
1967
2013
),
1968
2014
);
1969
2015
2016
+ // The hint's opacity animates from 1.0 to 0.0.
2017
+ // The animation's duration is 200ms.
2018
+ {
2019
+ await tester.pump (const Duration (milliseconds: 50 ));
2020
+ final double hintOpacity50ms = getOpacity (tester, 'hint' );
2021
+ expect (hintOpacity50ms, inExclusiveRange (0.0 , 1.0 ));
2022
+ await tester.pump (const Duration (milliseconds: 50 ));
2023
+ final double hintOpacity100ms = getOpacity (tester, 'hint' );
2024
+ expect (hintOpacity100ms, inExclusiveRange (0.0 , hintOpacity50ms));
2025
+ }
2026
+
1970
2027
await tester.pumpAndSettle ();
1971
2028
expect (tester.getSize (find.byType (InputDecorator )), const Size (800.0 , 64.0 ));
1972
2029
expect (tester.getTopLeft (find.text ('text' )).dy, 32.0 );
@@ -1975,7 +2032,7 @@ void main() {
1975
2032
expect (tester.getBottomLeft (find.text ('label' )).dy, 24.0 );
1976
2033
expect (tester.getTopLeft (find.text ('hint' )).dy, 32.0 );
1977
2034
expect (tester.getBottomLeft (find.text ('hint' )).dy, 48.0 );
1978
- expect (getStaticOpacity (tester, 'hint' ), 0.0 );
2035
+ expect (getOpacity (tester, 'hint' ), 0.0 );
1979
2036
expect (getBorderBottom (tester), 64.0 );
1980
2037
expect (getBorderWeight (tester), 2.0 );
1981
2038
});
@@ -3213,7 +3270,7 @@ void main() {
3213
3270
expect (tester.getSize (find.byType (InputDecorator )), const Size (800.0 , 18.0 ));
3214
3271
expect (tester.getSize (find.text ('text' )).height, 16.0 );
3215
3272
expect (tester.getTopLeft (find.text ('text' )).dy, 1.0 );
3216
- expect (getStaticOpacity (tester, 'hint' ), 0.0 );
3273
+ expect (getOpacity (tester, 'hint' ), 0.0 );
3217
3274
expect (getBorderWeight (tester), 1.0 );
3218
3275
3219
3276
await tester.pumpWidget (
@@ -3236,7 +3293,7 @@ void main() {
3236
3293
expect (tester.getSize (find.byType (InputDecorator )), const Size (800.0 , 16.0 ));
3237
3294
expect (tester.getSize (find.text ('text' )).height, 16.0 );
3238
3295
expect (tester.getTopLeft (find.text ('text' )).dy, 0.0 );
3239
- expect (getStaticOpacity (tester, 'hint' ), 0.0 );
3296
+ expect (getOpacity (tester, 'hint' ), 0.0 );
3240
3297
expect (getBorderWeight (tester), 1.0 );
3241
3298
3242
3299
await tester.pumpWidget (
@@ -3258,7 +3315,7 @@ void main() {
3258
3315
expect (tester.getSize (find.byType (InputDecorator )), const Size (800.0 , kMinInteractiveDimension));
3259
3316
expect (tester.getSize (find.text ('text' )).height, 16.0 );
3260
3317
expect (tester.getTopLeft (find.text ('text' )).dy, 16.0 );
3261
- expect (getStaticOpacity (tester, 'hint' ), 0.0 );
3318
+ expect (getOpacity (tester, 'hint' ), 0.0 );
3262
3319
expect (getBorderWeight (tester), 0.0 );
3263
3320
});
3264
3321
@@ -3280,7 +3337,7 @@ void main() {
3280
3337
expect (tester.getSize (find.byType (InputDecorator )), const Size (800.0 , 16.0 ));
3281
3338
expect (tester.getSize (find.text ('text' )).height, 16.0 );
3282
3339
expect (tester.getTopLeft (find.text ('text' )).dy, 0.0 );
3283
- expect (getStaticOpacity (tester, 'hint' ), 0.0 );
3340
+ expect (getOpacity (tester, 'hint' ), 0.0 );
3284
3341
expect (getBorderWeight (tester), 0.0 );
3285
3342
3286
3343
// The hint should appear
@@ -5026,7 +5083,7 @@ void main() {
5026
5083
);
5027
5084
await tester.pumpAndSettle ();
5028
5085
5029
- expect (getStaticOpacity (tester, 'hint' ), 1.0 );
5086
+ expect (getOpacity (tester, 'hint' ), 1.0 );
5030
5087
});
5031
5088
5032
5089
testWidgets ('InputDecorator floating label width scales when focused' , (WidgetTester tester) async {
0 commit comments