animateTo method

Future<void> animateTo(
  1. FTime value, {
  2. Duration duration = const Duration(milliseconds: 100),
  3. Curve curve = Curves.decelerate,
})

Animates the controller to the given value.

Implementation

Future<void> animateTo(
  FTime value, {
  Duration duration = const Duration(milliseconds: 100),
  Curve curve = Curves.decelerate,
}) async {
  if (value == super.value) {
    return;
  }

  final values = [
    (value.hour / hourInterval).round(),
    (value.minute / minuteInterval).round(),
    if (!hours24) value.hour < 12 ? 0 : 1,
  ];

  try {
    _mutating = true;
    await Future.wait([
      for (final (index, wheel) in (_picker?.wheels ?? []).indexed)
        wheel.animateToItem(values[index], duration: duration, curve: curve),
    ]);
  } finally {
    _mutating = false;
  }
}