import 'package:flutter/material.dart'; class DatePickerField extends StatelessWidget { final DateTime? selectedDate; final Function(DateTime?) onDatePicked; const DatePickerField({Key? key, this.selectedDate, required this.onDatePicked}) : super(key: key); @override Widget build(BuildContext context) { return GestureDetector( onTap: () async { final DateTime? picked = await showDatePicker( context: context, initialDate: DateTime.now(), firstDate: DateTime.now(), lastDate: DateTime(2101), ); if (picked != null) { onDatePicked(picked); } }, child: Container( padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 16.0), decoration: BoxDecoration( color: Colors.white.withOpacity(0.1), borderRadius: BorderRadius.circular(10.0), ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( selectedDate == null ? 'Sélectionnez une date' : '${selectedDate!.day}/${selectedDate!.month}/${selectedDate!.year}', style: const TextStyle(color: Colors.white70), ), const Icon(Icons.calendar_today, color: Colors.white70), ], ), ), ); } }