Fused Date Picker - #29
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a “fused” date picker that lets users switch between Gregorian and Nepali calendars, renames the internal date-picker dialog class to a public API with a selection callback, and updates the example app accordingly.
- Publicly exposes NepaliDatePickerDialog (formerly
_DatePickerDialog) and adds anonDateChangedcallback. - Adds
FusedDatePickerDialogwith an AD/BS toggle and integrates it into the example app’s UI. - Bumps the example’s SDK constraint and refactors example project boilerplate (AppDelegates, buttons, main app structure).
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/src/material/date_picker.dart | Renamed _DatePickerDialog → NepaliDatePickerDialog, added onDateChanged and initialEntryMode fields |
| lib/src/fused_date_picker_dialog.dart | New FusedDatePickerDialog with AD/BS toggle and switch-based builder |
| lib/nepali_date_picker.dart | Exported the new fused dialog |
| example/pubspec.yaml | Updated Dart SDK lower bound to >=3.5.0 <4.0.0 |
| example/macos/Runner/AppDelegate.swift | Replaced @NSApplicationMain with @main |
| example/ios/Runner/AppDelegate.swift | Replaced @UIApplicationMain with @main |
| example/lib/modes/date_range_picker_widget.dart | Removed custom styling from example buttons |
| example/lib/modes/date_picker_widget.dart | Removed custom styling from example buttons |
| example/lib/modes/calendar_date_picker_widget.dart | Simplified sizing and text styles in TodayWidget |
| example/lib/main.dart | Refactored app entry into HomePage, added fused date-picker tab |
Comments suppressed due to low confidence (2)
lib/src/fused_date_picker_dialog.dart:1
- There are no unit or widget tests covering the new
FusedDatePickerDialog. Adding tests for mode toggling, date selection, and dialog result will help prevent regressions.
import 'package:flutter/material.dart';
lib/src/material/date_picker.dart:216
- The new
initialEntryModefield is never initialized in the constructor. Add a constructor parameter or provide a default value to avoid a compilation error.
final DatePickerEntryMode initialEntryMode;
| @override | ||
| Widget build(BuildContext context) { | ||
| return DefaultTabController( | ||
| length: 5, |
There was a problem hiding this comment.
The DefaultTabController length (5) does not match the number of tabs and views (4), which will trigger an assertion failure. Please update the length to match.
| return Column( | ||
| mainAxisAlignment: MainAxisAlignment.center, | ||
| children: [ | ||
| _AdBsToggle( | ||
| onChanged: (mode) { | ||
| _mode = mode; | ||
| setState(() {}); | ||
| }, | ||
| ), | ||
| switch (_mode) { | ||
| CalendarMode.ad => DatePickerDialog( | ||
| firstDate: widget.firstDate, | ||
| lastDate: widget.lastDate, | ||
| currentDate: _selectedDate, | ||
| ), | ||
| CalendarMode.bs => NepaliDatePickerDialog( | ||
| initialDate: NepaliDateTime.now(), | ||
| firstDate: widget.firstDate.toNepaliDateTime(), | ||
| lastDate: widget.lastDate.toNepaliDateTime(), | ||
| onDateChanged: (date) { | ||
| _selectedDate = date.toDateTime(); | ||
| }, | ||
| ), | ||
| } | ||
| ], |
There was a problem hiding this comment.
[nitpick] The toggle control is rendered outside of a dialog container. Consider wrapping the toggle and picker widgets in a Dialog or AlertDialog so the entire UI appears as a single modal dialog.
| return Column( | |
| mainAxisAlignment: MainAxisAlignment.center, | |
| children: [ | |
| _AdBsToggle( | |
| onChanged: (mode) { | |
| _mode = mode; | |
| setState(() {}); | |
| }, | |
| ), | |
| switch (_mode) { | |
| CalendarMode.ad => DatePickerDialog( | |
| firstDate: widget.firstDate, | |
| lastDate: widget.lastDate, | |
| currentDate: _selectedDate, | |
| ), | |
| CalendarMode.bs => NepaliDatePickerDialog( | |
| initialDate: NepaliDateTime.now(), | |
| firstDate: widget.firstDate.toNepaliDateTime(), | |
| lastDate: widget.lastDate.toNepaliDateTime(), | |
| onDateChanged: (date) { | |
| _selectedDate = date.toDateTime(); | |
| }, | |
| ), | |
| } | |
| ], | |
| return AlertDialog( | |
| content: Column( | |
| mainAxisSize: MainAxisSize.min, | |
| children: [ | |
| _AdBsToggle( | |
| onChanged: (mode) { | |
| _mode = mode; | |
| setState(() {}); | |
| }, | |
| ), | |
| switch (_mode) { | |
| CalendarMode.ad => DatePickerDialog( | |
| firstDate: widget.firstDate, | |
| lastDate: widget.lastDate, | |
| currentDate: _selectedDate, | |
| ), | |
| CalendarMode.bs => NepaliDatePickerDialog( | |
| initialDate: NepaliDateTime.now(), | |
| firstDate: widget.firstDate.toNepaliDateTime(), | |
| lastDate: widget.lastDate.toNepaliDateTime(), | |
| onDateChanged: (date) { | |
| _selectedDate = date.toDateTime(); | |
| }, | |
| ), | |
| } | |
| ], | |
| ), |
For testing out the fused date picker: