move method

Future<void> move(
  1. TraversalDirection direction,
  2. TextDirection textDirection, {
  3. Duration duration = const Duration(milliseconds: 200),
  4. Curve curve = Curves.ease,
})
inherited

Moves focus one date horizontally or one row vertically in direction, honoring textDirection. Skips unselectable dates and pages across as needed. Does nothing if no selectable date exists in that direction within start and end.

Implementation

Future<void> move(
  TraversalDirection direction,
  TextDirection textDirection, {
  Duration duration = const Duration(milliseconds: 200),
  Curve curve = Curves.ease,
}) async {
  final step = switch ((direction, textDirection)) {
    (.left, .ltr) || (.right, .rtl) => -1,
    (.right, .ltr) || (.left, .rtl) => 1,
    (.up, _) => -_columns,
    (.down, _) => _columns,
  };

  var next = _step(_focused ?? _current, step);
  while (!next.isBefore(start) && !next.isAfter(end)) {
    if (_selectable(next)) {
      await focus(next, duration: duration, curve: curve);
      return;
    }
    next = _step(next, step);
  }
}