first draft
This commit is contained in:
@@ -45,3 +45,73 @@ class Item {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class StoreLayout {
|
||||
final String id;
|
||||
String name;
|
||||
String owner;
|
||||
double? latitude;
|
||||
double? longitude;
|
||||
String? address;
|
||||
bool isPublic;
|
||||
|
||||
StoreLayout({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.owner,
|
||||
this.latitude,
|
||||
this.longitude,
|
||||
this.address,
|
||||
this.isPublic = false,
|
||||
});
|
||||
|
||||
factory StoreLayout.fromJson(Map<String, dynamic> json) {
|
||||
double? parseCoord(dynamic value) {
|
||||
if (value == null) return null;
|
||||
if (value is double) return value;
|
||||
if (value is int) return value.toDouble();
|
||||
return double.tryParse(value.toString());
|
||||
}
|
||||
|
||||
return StoreLayout(
|
||||
id: json['id'] as String,
|
||||
name: json['name'] as String? ?? '',
|
||||
owner: json['owner'] as String? ?? '',
|
||||
latitude: parseCoord(json['latitude']),
|
||||
longitude: parseCoord(json['longitude']),
|
||||
address: json['address'] as String?,
|
||||
isPublic: json['isPublic'] as bool? ?? false,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class StoreSection {
|
||||
final String id;
|
||||
final String layoutId;
|
||||
String name;
|
||||
int position;
|
||||
String? category;
|
||||
|
||||
StoreSection({
|
||||
required this.id,
|
||||
required this.layoutId,
|
||||
required this.name,
|
||||
this.position = 0,
|
||||
this.category,
|
||||
});
|
||||
|
||||
factory StoreSection.fromJson(Map<String, dynamic> json) {
|
||||
int parsePosition(dynamic value) {
|
||||
if (value is int) return value;
|
||||
return int.tryParse(value.toString()) ?? 0;
|
||||
}
|
||||
|
||||
return StoreSection(
|
||||
id: json['id'] as String,
|
||||
layoutId: json['layout'] as String? ?? '',
|
||||
name: json['name'] as String? ?? '',
|
||||
position: parsePosition(json['position']),
|
||||
category: json['category'] as String?,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user