diet-guard/app/lib/widgets/pickers/year_wheel.dart
Krzysztof kuhy Rudnicki 49144a2c49 Move the app to material_ui for Flutter 3.50
Flutter 3.50 deprecates package:flutter/material.dart; 73 deprecation
infos failed flutter analyze --fatal-infos, and four Dart pins were
behind (crdt_sync_flutter 0.8.2, flutter_local_notifications 23.0.2,
github_device_auth 0.5.0, sync_settings_ui 0.8.2). Those UI packages
now sit on material_ui, so the app has to as well or their widgets lose
MaterialLocalizations.

Imports swap one-for-one and dart fix re-sorted the directives; no
behaviour change. analyze is clean and all six test shards pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WzxdWWfb63jncj9Lca2jeX
2026-11-16 09:25:34 +01:00

51 lines
1.4 KiB
Dart

/// The date picker's year wheel: numerals, no loop.
library;
import 'package:diet_guard_app/widgets/pickers/numeral_wheel.dart';
import 'package:material_ui/material_ui.dart';
/// Out-of-range years listed beyond each bound, dimmed and inert, so the
/// wheel's ends read as limits rather than as a list that just stops.
const int kYearWheelPad = 2;
/// A non-looping wheel of the years [firstYear]..[lastYear], plus
/// [kYearWheelPad] dimmed, inert years past each end (a wheel dragged onto
/// one springs back).
class YearWheel extends StatelessWidget {
/// Creates a [YearWheel].
const YearWheel({
required this.firstYear,
required this.lastYear,
required this.value,
required this.onChanged,
this.autofocus = false,
super.key,
});
/// Earliest listed year.
final int firstYear;
/// Latest listed year.
final int lastYear;
/// The shown year.
final int value;
/// Called with a newly centred year.
final ValueChanged<int> onChanged;
/// Whether the wheel takes keyboard focus on open (the birth-date flow).
final bool autofocus;
@override
Widget build(BuildContext context) => NumeralWheel(
count: lastYear - firstYear + 1 + 2 * kYearWheelPad,
offset: firstYear - kYearWheelPad,
enabled: (y) => y >= firstYear && y <= lastYear,
value: value,
onChanged: onChanged,
semanticLabel: 'Year',
autofocus: autofocus,
);
}