2024-06-10 01:06:56 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
class CalendarFloatingButton extends StatelessWidget {
|
2024-09-06 23:38:03 +00:00
|
|
|
final DateTime startFromDate;
|
|
|
|
final Function(DateTime) onDateSelected;
|
2024-06-10 01:06:56 +00:00
|
|
|
|
2024-09-06 23:38:03 +00:00
|
|
|
const CalendarFloatingButton(
|
|
|
|
{super.key, required this.startFromDate, required this.onDateSelected});
|
2024-06-10 01:06:56 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return FloatingActionButton(
|
2024-09-06 23:38:03 +00:00
|
|
|
onPressed: () async {
|
|
|
|
var datePicked = await showDatePicker(
|
|
|
|
locale: const Locale('de'),
|
|
|
|
context: context,
|
|
|
|
initialDate: startFromDate,
|
|
|
|
currentDate: DateTime.now(),
|
|
|
|
firstDate: DateTime.now().subtract(const Duration(days: 365 * 10)),
|
|
|
|
lastDate: DateTime.now(),
|
|
|
|
);
|
2024-06-10 01:06:56 +00:00
|
|
|
|
2024-09-06 23:38:03 +00:00
|
|
|
if (!context.mounted) return;
|
|
|
|
|
|
|
|
onDateSelected(datePicked ?? DateTime.now());
|
|
|
|
},
|
|
|
|
heroTag: "calendarFAB",
|
|
|
|
child: const Icon(Icons.today),
|
|
|
|
);
|
2024-06-10 01:06:56 +00:00
|
|
|
}
|
|
|
|
}
|