diet-guard/app/lib/widgets/pickers/month_chips.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

47 lines
1.2 KiB
Dart

/// The month row of the date picker: numerals 1-12 instead of month names.
library;
import 'package:diet_guard_app/widgets/pickers/numeral_cell.dart';
import 'package:material_ui/material_ui.dart';
/// Twelve numeral chips in two rows of six; months wholly outside the bounds
/// are dimmed and inert.
class MonthChips extends StatelessWidget {
/// Creates a [MonthChips].
const MonthChips({
required this.year,
required this.selected,
required this.allowed,
required this.onTap,
super.key,
});
/// The shown year (for the spoken month names).
final int year;
/// The shown month, 1-12.
final int selected;
/// Whether month 1-12 has any day within the bounds.
final bool Function(int month) allowed;
/// Called with a tapped allowed month.
final ValueChanged<int> onTap;
@override
Widget build(BuildContext context) {
final l10n = MaterialLocalizations.of(context);
return numeralRows(6, aspectRatio: 1.6, [
for (var m = 1; m <= 12; m++)
NumeralCell(
key: ValueKey('month-$m'),
label: '$m',
semanticLabel: l10n.formatMonthYear(DateTime(year, m)),
onTap: () => onTap(m),
enabled: allowed(m),
selected: m == selected,
),
]);
}
}