fix: flutter_map latlng bounds assertion et overflow du dropdown des depôts
This commit is contained in:
@@ -53,20 +53,9 @@ class RouteMapWidget extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LatLngBounds? _computeBounds(List<List<LatLng>> allPoints) {
|
LatLngBounds? _computeBounds(List<List<LatLng>> allPoints) {
|
||||||
double? minLat, maxLat, minLng, maxLng;
|
final flat = allPoints.expand((e) => e).toList();
|
||||||
for (final pts in allPoints) {
|
if (flat.isEmpty) return null;
|
||||||
for (final p in pts) {
|
return LatLngBounds.fromPoints(flat);
|
||||||
minLat = minLat == null ? p.latitude : p.latitude < minLat ? p.latitude : minLat;
|
|
||||||
maxLat = maxLat == null ? p.latitude : p.latitude > maxLat ? p.latitude : maxLat;
|
|
||||||
minLng = minLng == null ? p.longitude : p.longitude < minLng ? p.longitude : minLng;
|
|
||||||
maxLng = maxLng == null ? p.longitude : p.longitude > maxLng ? p.longitude : maxLng;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (minLat == null) return null;
|
|
||||||
return LatLngBounds(
|
|
||||||
LatLng(minLat - 0.02, minLng! - 0.02),
|
|
||||||
LatLng(maxLat! + 0.02, maxLng! + 0.02),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -303,6 +303,7 @@ class _TravelCostDialogState extends State<TravelCostDialog> {
|
|||||||
else
|
else
|
||||||
DropdownButtonFormField<DepotModel>(
|
DropdownButtonFormField<DepotModel>(
|
||||||
value: _selectedDepot,
|
value: _selectedDepot,
|
||||||
|
isExpanded: true,
|
||||||
decoration: const InputDecoration(
|
decoration: const InputDecoration(
|
||||||
border: OutlineInputBorder(),
|
border: OutlineInputBorder(),
|
||||||
prefixIcon: Icon(Icons.warehouse_outlined),
|
prefixIcon: Icon(Icons.warehouse_outlined),
|
||||||
@@ -310,17 +311,9 @@ class _TravelCostDialogState extends State<TravelCostDialog> {
|
|||||||
items: _depots
|
items: _depots
|
||||||
.map((d) => DropdownMenuItem(
|
.map((d) => DropdownMenuItem(
|
||||||
value: d,
|
value: d,
|
||||||
child: Column(
|
child: Text(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
'${d.name} — ${d.address}',
|
||||||
mainAxisSize: MainAxisSize.min,
|
overflow: TextOverflow.ellipsis,
|
||||||
children: [
|
|
||||||
Text(d.name,
|
|
||||||
style: const TextStyle(fontWeight: FontWeight.w600)),
|
|
||||||
Text(d.address,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 11, color: Colors.grey),
|
|
||||||
overflow: TextOverflow.ellipsis),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
))
|
))
|
||||||
.toList(),
|
.toList(),
|
||||||
@@ -337,6 +330,7 @@ class _TravelCostDialogState extends State<TravelCostDialog> {
|
|||||||
else
|
else
|
||||||
DropdownButtonFormField<VehicleModel>(
|
DropdownButtonFormField<VehicleModel>(
|
||||||
value: _selectedVehicle,
|
value: _selectedVehicle,
|
||||||
|
isExpanded: true,
|
||||||
decoration: const InputDecoration(
|
decoration: const InputDecoration(
|
||||||
border: OutlineInputBorder(),
|
border: OutlineInputBorder(),
|
||||||
prefixIcon: Icon(Icons.directions_car_outlined),
|
prefixIcon: Icon(Icons.directions_car_outlined),
|
||||||
@@ -345,7 +339,9 @@ class _TravelCostDialogState extends State<TravelCostDialog> {
|
|||||||
.map((v) => DropdownMenuItem(
|
.map((v) => DropdownMenuItem(
|
||||||
value: v,
|
value: v,
|
||||||
child: Text(
|
child: Text(
|
||||||
'${v.name} — ${v.consumptionPer100km} ${v.consumptionUnit} | Cat. péage ${v.tollCategoryId}'),
|
'${v.name} — ${v.consumptionPer100km} ${v.consumptionUnit} | Cat. péage ${v.tollCategoryId}',
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
))
|
))
|
||||||
.toList(),
|
.toList(),
|
||||||
onChanged: (v) => setState(() => _selectedVehicle = v),
|
onChanged: (v) => setState(() => _selectedVehicle = v),
|
||||||
|
|||||||
Reference in New Issue
Block a user