highlight method
this function can be called multiple times. every call will reset the highlight style.
Implementation
Future highlight(
{bool cancelExisting: true,
Duration highlightDuration: _highlightDuration,
bool animated: true}) async {
if (!mounted) return null;
if (cancelExisting) {
_cancelAllHighlights(this);
}
if (_highlights.containsKey(this)) {
assert(_controller != null);
_controller!.stop();
}
if (_controller == null) {
_controller = new AnimationController(vsync: this);
_highlights[this] = _controller;
}
final startKey0 = _startKey = DateTime.now();
const animationShow = 1.0;
setState(() {});
if (animated)
await catchAnimationCancel(_controller!
.animateTo(animationShow, duration: scrollAnimationDuration));
else
_controller!.value = animationShow;
await Future.delayed(highlightDuration);
if (startKey0 == _startKey) {
if (mounted) {
setState(() {});
const animationHide = 0.0;
if (animated)
await catchAnimationCancel(_controller!
.animateTo(animationHide, duration: scrollAnimationDuration));
else
_controller!.value = animationHide;
}
if (startKey0 == _startKey) {
_controller = null;
_highlights.remove(this);
}
}
return null;
}