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

68 lines
2.1 KiB
Dart

/// Icon-only replacements for `showDatePicker`, `showDateRangePicker` and
/// `showTimePicker`, which paint "Select date", "Cancel", "OK" and tooltips.
///
/// Same arguments as the framework calls, so a call site changes by one
/// function name. Dropped on purpose: the weekday header, month names and
/// both text-entry modes (see the textgate rework report).
library;
import 'package:diet_guard_app/widgets/pickers/date_dialog.dart';
import 'package:diet_guard_app/widgets/pickers/date_selection.dart';
import 'package:diet_guard_app/widgets/pickers/time_dialog.dart';
import 'package:material_ui/material_ui.dart';
/// Picks one day in [firstDate]..[lastDate]; null when cancelled.
///
/// [initialDatePickerMode] `year` focuses the year wheel first.
Future<DateTime?> pickDate({
required BuildContext context,
required DateTime firstDate,
required DateTime lastDate,
DateTime? initialDate,
DatePickerMode initialDatePickerMode = DatePickerMode.day,
}) => showDialog<DateTime>(
context: context,
builder: (_) => DateDialog(
selection: DateSelection.single(
first: firstDate,
last: lastDate,
initial: initialDate,
),
startOnYear: initialDatePickerMode == DatePickerMode.year,
),
);
/// Picks a range of days in [firstDate]..[lastDate] by two taps; null when
/// cancelled.
Future<DateTimeRange?> pickDateRange({
required BuildContext context,
required DateTime firstDate,
required DateTime lastDate,
DateTimeRange? initialDateRange,
}) => showDialog<DateTimeRange>(
context: context,
builder: (_) => DateDialog(
selection: DateSelection.range(
first: firstDate,
last: lastDate,
initial: initialDateRange,
),
),
);
/// Picks a 24 h time whose minute of day lies in [minMinute]..[maxMinute];
/// null when cancelled.
Future<TimeOfDay?> pickTime({
required BuildContext context,
required TimeOfDay initialTime,
int minMinute = 0,
int maxMinute = 24 * 60 - 1,
}) => showDialog<TimeOfDay>(
context: context,
builder: (_) => TimeDialog(
initialMinute: initialTime.hour * 60 + initialTime.minute,
minMinute: minMinute,
maxMinute: maxMinute,
),
);