animateToMonthPicker method
Shows the month picker for the given date's year, or the current year if date is null.
If the month picker is already shown, its grid animates to the year; otherwise it is shown immediately.
Testing
To avoid timeouts in widget tests, always wrap the returned Future in unawaited.
testWidgets('shows', (tester) async {
await tester.pumpWidget(...);
unawaited(controller.show());
await tester.pumpAndSettle();
});
Implementation
Future<void> animateToMonthPicker([
DateTime? date,
Duration duration = const Duration(milliseconds: 200),
Curve curve = Curves.ease,
]) async {
final target = _clamp(start, switch (date) {
null => _currentMonth,
final m => .utc(m.year, m.month),
}, end);
if (month.controller.hasClients) {
await month.animateTo(target, duration: duration, curve: curve);
} else {
_reattach(month, .month, target);
}
}