diff --git a/packages/flutter/lib/src/material/input_decorator.dart b/packages/flutter/lib/src/material/input_decorator.dart index bc584fd6c0..5c3b54a812 100644 --- a/packages/flutter/lib/src/material/input_decorator.dart +++ b/packages/flutter/lib/src/material/input_decorator.dart @@ -166,6 +166,7 @@ class _BorderContainer extends StatefulWidget { class _BorderContainerState extends State<_BorderContainer> with TickerProviderStateMixin { static const Duration _kFocusInDuration = Duration(milliseconds: 45); + static const Duration _kFocusOutDuration = Duration(milliseconds: 15); static const Duration _kHoverDuration = Duration(milliseconds: 15); AnimationController _controller; @@ -183,7 +184,7 @@ class _BorderContainerState extends State<_BorderContainer> with TickerProviderS super.initState(); _focusColorController = AnimationController( duration: _kFocusInDuration, - // TODO(gspencer): use reverseDuration set to 15ms, once available. + reverseDuration: _kFocusOutDuration, value: widget.isFocused ? 1.0 : 0.0, vsync: this, ); diff --git a/packages/flutter/lib/src/material/tooltip.dart b/packages/flutter/lib/src/material/tooltip.dart index fb25f21db9..ca0177c7df 100644 --- a/packages/flutter/lib/src/material/tooltip.dart +++ b/packages/flutter/lib/src/material/tooltip.dart @@ -149,7 +149,11 @@ class _TooltipState extends State with SingleTickerProviderStateMixin { void initState() { super.initState(); _mouseIsConnected = RendererBinding.instance.mouseTracker.mouseIsConnected; - _controller = AnimationController(duration: _fadeInDuration, vsync: this) + _controller = AnimationController( + duration: _fadeInDuration, + reverseDuration: _fadeOutDuration, + vsync: this, + ) ..addStatusListener(_handleStatusChanged); // Listen to see when a mouse is added. RendererBinding.instance.mouseTracker.addListener(_handleMouseTrackerChange); @@ -226,7 +230,6 @@ class _TooltipState extends State with SingleTickerProviderStateMixin { void _createNewEntry() { final RenderBox box = context.findRenderObject(); final Offset target = box.localToGlobal(box.size.center(Offset.zero)); - assert(_fadeOutDuration < _fadeInDuration); // We create this widget outside of the overlay entry's builder to prevent // updated values from happening to leak into the overlay when the overlay @@ -239,14 +242,6 @@ class _TooltipState extends State with SingleTickerProviderStateMixin { animation: CurvedAnimation( parent: _controller, curve: Curves.fastOutSlowIn, - // Add an interval here to make the fade out use a different (shorter) - // duration than the fade in. If _kFadeOutDuration is made longer than - // _kFadeInDuration, then the equation below will need to change. - reverseCurve: Interval( - 0.0, - _fadeOutDuration.inMilliseconds / _fadeInDuration.inMilliseconds, - curve: Curves.fastOutSlowIn, - ), ), target: target, verticalOffset: widget.verticalOffset, diff --git a/packages/flutter/test/material/input_decorator_test.dart b/packages/flutter/test/material/input_decorator_test.dart index 6786d25880..586c833556 100644 --- a/packages/flutter/test/material/input_decorator_test.dart +++ b/packages/flutter/test/material/input_decorator_test.dart @@ -2140,8 +2140,7 @@ void main() { ); expect(getContainerColor(tester), equals(focusColor)); - // TODO(gspencer): convert this to 15ms once reverseDuration for AnimationController lands. - await tester.pump(const Duration(milliseconds: 45)); + await tester.pump(const Duration(milliseconds: 15)); expect(getContainerColor(tester), equals(fillColor)); });