feat: implement core architecture, design system, localization, and trip features for both driver and rider apps.
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// نموذج مكان من نتائج البحث (autocomplete / geocode).
|
||||
class PlaceModel extends Equatable {
|
||||
final String? placeId;
|
||||
final String name;
|
||||
final String? address;
|
||||
final double lat;
|
||||
final double lng;
|
||||
|
||||
const PlaceModel({
|
||||
this.placeId,
|
||||
required this.name,
|
||||
this.address,
|
||||
required this.lat,
|
||||
required this.lng,
|
||||
});
|
||||
|
||||
factory PlaceModel.fromJson(Map<String, dynamic> j) => PlaceModel(
|
||||
placeId: j['placeId'] as String?,
|
||||
name: (j['description'] ?? j['name'] ?? '') as String,
|
||||
address: j['address'] as String?,
|
||||
lat: (j['lat'] as num).toDouble(),
|
||||
lng: (j['lng'] as num).toDouble(),
|
||||
);
|
||||
|
||||
factory PlaceModel.fromGeocode(Map<String, dynamic> j) => PlaceModel(
|
||||
placeId: j['placeId'] as String?,
|
||||
name: (j['name'] ?? j['formattedAddress'] ?? '') as String,
|
||||
address: j['formattedAddress'] as String?,
|
||||
lat: (j['lat'] as num).toDouble(),
|
||||
lng: (j['lng'] as num).toDouble(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
if (placeId != null) 'placeId': placeId,
|
||||
'name': name,
|
||||
if (address != null) 'address': address,
|
||||
'lat': lat,
|
||||
'lng': lng,
|
||||
};
|
||||
|
||||
@override
|
||||
List<Object?> get props => [placeId, name, address, lat, lng];
|
||||
}
|
||||
Reference in New Issue
Block a user