showCalendarMulti static method
달력 호출(multi)
Implementation
static Future<List<DateTime>?> showCalendarMulti({
// 초기값
List<DateTime>? initDateTime,
// 최소날짜
DateTime? minDateTime,
// 최대날짜
DateTime? maxDateTime,
// 최대 개수
int selectMaxCount = 5,
required,
final String? errorFontfamily,
final String? lastMonthString,
final String? nextMonthString,
final String? cancelString,
final String? okString,
final String? selectDateString,
final String? daysMaxString,
}) async {
Set<DateTime> calendarSet = {};
var result = await showCalendarDatePicker2Dialog(
context: clueNavigatorKey.currentContext!,
// 날짜 초기값
value: initDateTime ?? [],
config: CalendarDatePicker2WithActionButtonsConfig(
selectedDayHighlightColor: MyColors.xFF8299FF,
selectedRangeHighlightColor: MyColors.xFF8299FF,
dayTextStyle: const TextStyle(fontSize: 12, color: MyColors.xFF000000),
calendarType: CalendarDatePicker2Type.multi,
dayBuilder: ({required date, decoration, isDisabled, isSelected, isToday, textStyle}) {
if (isSelected == true) {
calendarSet.add(date);
} else {
calendarSet.removeWhere((element) => element.yyyyMMdd == date.yyyyMMdd);
}
return null;
},
// 현재날짜 표시(테두리)
currentDate: DateTime.now(),
// 조건 - 최소날짜
firstDate: minDateTime,
// 조건 - 최대날짜
lastDate: maxDateTime,
// < 버튼
lastMonthIcon: Tooltip(message: lastMonthString ?? "last_month", child: MyImages.leftArrow),
// > 버튼
nextMonthIcon: Tooltip(message: nextMonthString ?? "next_month", child: MyImages.rightArrow),
buttonPadding: EdgeInsets.zero,
// 취소버튼
cancelButton: TextButton(
onPressed: () {
Navigator.pop(clueNavigatorKey.currentContext!);
},
child: Text(
cancelString ?? "cancel",
style: MyTextStyle.size14,
),
),
// 확인버튼
okButton: TextButton(
onPressed: () {
if (calendarSet.isEmpty) {
ClueOverlay.showErrorToast(selectDateString ?? "select_date");
} else if (calendarSet.length > selectMaxCount) {
ClueOverlay.showErrorToast(daysMaxString ?? "days_maximum");
} else {
Navigator.pop(clueNavigatorKey.currentContext!, calendarSet.toList());
}
},
child: Text(
okString ?? "ok",
style: MyTextStyle.size14,
),
),
),
// 다이얼로그 크기
dialogSize: const Size(500, 450),
// 다이얼로그 배경색
dialogBackgroundColor: MyColors.xFFFFFFFF,
// 네비게이션 라우트 이름
routeSettings: const RouteSettings(name: 'showCalendarMulti'),
// 다이얼로그 테두리
borderRadius: BorderRadius.circular(5),
);
return result?.map((e) => e!).toList();
}