1
0
mirror of https://github.com/nisrulz/flutter-examples.git synced 2025-11-09 04:58:58 +00:00

New Example - Calendar (#91)

This commit is contained in:
Ishaan Kesarwani
2022-10-22 23:59:43 +05:30
committed by GitHub
parent d9cc97a7ea
commit 91d4d1b868
100 changed files with 7300 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
import 'package:flutter_date_pickers/src/day_type.dart';
import 'package:flutter_date_pickers/src/i_selectable_picker.dart';
import 'package:flutter_test/flutter_test.dart';
import 'date_time_utils.dart';
void main() {
group("DaySelectable test.", () {
test("getDayType() returns correct type for different dates", () {
final selectedDate = DateTime.now();
final firstDate = selectedDate.subtract(const Duration(days: 10));
final lastDate = selectedDate.add(const Duration(days: 10));
final disabledDate = selectedDate.subtract(const Duration(days: 1));
// ignore: prefer_function_declarations_over_variables
final selectablePredicate = (DateTime d)
=> !DateTimeUtils.sameDate(d, disabledDate);
final selectableLogic = DaySelectable(
selectedDate, firstDate, lastDate,
selectableDayPredicate: selectablePredicate);
final selectedDateType = selectableLogic.getDayType(selectedDate);
final notSelectedEnabledDateType = selectableLogic.getDayType(firstDate);
final disabledDateType = selectableLogic.getDayType(disabledDate);
expect(selectedDateType, DayType.single);
expect(notSelectedEnabledDateType, DayType.notSelected);
expect(disabledDateType, DayType.disabled);
});
});
}