Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import 'package:flutter/material.dart';
import 'package:table_calendar/table_calendar.dart';
import 'package:universal_platform/universal_platform.dart';

final kFirstDay = DateTime.utc(1970);
// Dates are also used for values such as birthdays, which can predate Unix
// epoch. Keep the lower bound broad enough for historical dates while avoiding
// the impractically large range before the Gregorian calendar.
final kFirstDay = DateTime.utc(1900);
final kLastDay = DateTime.utc(2100);

class DatePicker extends StatefulWidget {
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Expand Down
23 changes: 23 additions & 0 deletions frontend/appflowy_flutter/test/widget_test/date_picker_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,29 @@ void main() {
);

group('AppFlowy date picker:', () {
testWidgets('supports dates before the Unix epoch', (tester) async {
await tester.pumpWidget(
const WidgetTestApp(
child: _MockDatePicker(),
),
);
await tester.pumpAndSettle();

final calendar = tester.widget<TableCalendar>(
find.byType(TableCalendar),
);
expect(calendar.firstDay, DateTime.utc(1900));

final dateTextField = find.byKey(
const ValueKey('date_time_text_field_date'),
);
await tester.enterText(dateTextField, 'Jan 25, 1958');
await tester.testTextInput.receiveAction(TextInputAction.done);
await tester.pumpAndSettle();

expect(getMockState(tester).data.dateTime, DateTime(1958, 1, 25));
});

testWidgets('default state', (tester) async {
await tester.pumpWidget(
const WidgetTestApp(
Expand Down
Loading