import 'package:flutter/material.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; import '../screens/location/location_picker_Screen.dart'; class LocationField extends StatelessWidget { final String location; final LatLng? selectedLatLng; final Function(LatLng?) onLocationPicked; const LocationField({Key? key, required this.location, this.selectedLatLng, required this.onLocationPicked}) : super(key: key); @override Widget build(BuildContext context) { return GestureDetector( onTap: () async { final LatLng? pickedLocation = await Navigator.push( context, MaterialPageRoute( builder: (context) => const LocationPickerScreen(), ), ); if (pickedLocation != null) { onLocationPicked(pickedLocation); } }, 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( selectedLatLng == null ? 'Sélectionnez une localisation' : 'Localisation: $location', style: const TextStyle(color: Colors.white70), ), const Icon(Icons.location_on, color: Colors.white70), ], ), ), ); } }