Unverified Commit 255b71f1 authored by Markus Aksli's avatar Markus Aksli Committed by GitHub

Switch hint text to Opacity instead of AnimatedOpacity (#107156)

parent fd54ddf5
...@@ -2157,10 +2157,8 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat ...@@ -2157,10 +2157,8 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
final TextBaseline textBaseline = labelStyle.textBaseline!; final TextBaseline textBaseline = labelStyle.textBaseline!;
final TextStyle hintStyle = _getInlineHintStyle(themeData); final TextStyle hintStyle = _getInlineHintStyle(themeData);
final Widget? hint = decoration!.hintText == null ? null : AnimatedOpacity( final Widget? hint = decoration!.hintText == null ? null : Opacity(
opacity: (isEmpty && !_hasInlineLabel) ? 1.0 : 0.0, opacity: (isEmpty && !_hasInlineLabel) ? 1.0 : 0.0,
duration: _kTransitionDuration,
curve: _kTransitionCurve,
alwaysIncludeSemantics: true, alwaysIncludeSemantics: true,
child: Text( child: Text(
decoration!.hintText!, decoration!.hintText!,
......
...@@ -61,13 +61,12 @@ void main() { ...@@ -61,13 +61,12 @@ void main() {
} }
double textOpacity(WidgetTester tester, String textValue) { double textOpacity(WidgetTester tester, String textValue) {
final FadeTransition opacityWidget = tester.widget<FadeTransition>( return tester.widget<Opacity>(
find.ancestor( find.ancestor(
of: find.text(textValue), of: find.text(textValue),
matching: find.byType(FadeTransition), matching: find.byType(Opacity),
).first, ).first,
); ).opacity;
return opacityWidget.opacity.value;
} }
group('InputDatePickerFormField', () { group('InputDatePickerFormField', () {
......
...@@ -131,6 +131,15 @@ double getOpacity(WidgetTester tester, Finder finder) { ...@@ -131,6 +131,15 @@ double getOpacity(WidgetTester tester, Finder finder) {
).opacity.value; ).opacity.value;
} }
double getStaticOpacity(WidgetTester tester, Finder finder) {
return tester.widget<Opacity>(
find.ancestor(
of: finder,
matching: find.byType(Opacity),
).first,
).opacity;
}
class TestFormatter extends TextInputFormatter { class TestFormatter extends TextInputFormatter {
TestFormatter(this.onFormatEditUpdate); TestFormatter(this.onFormatEditUpdate);
FormatEditUpdateCallback onFormatEditUpdate; FormatEditUpdateCallback onFormatEditUpdate;
...@@ -3708,7 +3717,7 @@ void main() { ...@@ -3708,7 +3717,7 @@ void main() {
// Neither the prefix or the suffix should initially be visible, only the hint. // Neither the prefix or the suffix should initially be visible, only the hint.
expect(getOpacity(tester, find.text('Prefix')), 0.0); expect(getOpacity(tester, find.text('Prefix')), 0.0);
expect(getOpacity(tester, find.text('Suffix')), 0.0); expect(getOpacity(tester, find.text('Suffix')), 0.0);
expect(getOpacity(tester, find.text('Hint')), 1.0); expect(getStaticOpacity(tester, find.text('Hint')), 1.0);
await tester.tap(find.byKey(secondKey)); await tester.tap(find.byKey(secondKey));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
...@@ -3716,7 +3725,7 @@ void main() { ...@@ -3716,7 +3725,7 @@ void main() {
// Focus the Input. The hint, prefix, and suffix should appear // Focus the Input. The hint, prefix, and suffix should appear
expect(getOpacity(tester, find.text('Prefix')), 1.0); expect(getOpacity(tester, find.text('Prefix')), 1.0);
expect(getOpacity(tester, find.text('Suffix')), 1.0); expect(getOpacity(tester, find.text('Suffix')), 1.0);
expect(getOpacity(tester, find.text('Hint')), 1.0); expect(getStaticOpacity(tester, find.text('Hint')), 1.0);
// Enter some text, and the hint should disappear and the prefix and suffix // Enter some text, and the hint should disappear and the prefix and suffix
// should continue to be visible // should continue to be visible
...@@ -3725,7 +3734,7 @@ void main() { ...@@ -3725,7 +3734,7 @@ void main() {
expect(getOpacity(tester, find.text('Prefix')), 1.0); expect(getOpacity(tester, find.text('Prefix')), 1.0);
expect(getOpacity(tester, find.text('Suffix')), 1.0); expect(getOpacity(tester, find.text('Suffix')), 1.0);
expect(getOpacity(tester, find.text('Hint')), 0.0); expect(getStaticOpacity(tester, find.text('Hint')), 0.0);
// Check and make sure that the right styles were applied. // Check and make sure that the right styles were applied.
final Text prefixText = tester.widget(find.text('Prefix')); final Text prefixText = tester.widget(find.text('Prefix'));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment