import 'dart:ffi';
import './location.dart';
class Walker {
String name;
Location location;
int yrsExp;
double price;
String email;
String? imgUrl;
String? description;
bool? trainingCert;
bool? firstaid;
Set? matches = {};
Walker({
required this.name,
required this.location,
required this.yrsExp,
required this.price,
required this.email,
this.imgUrl,
this.description,
this.trainingCert,
this.firstaid,
this.matches
});
Map<dynamic, dynamic> toJson() => <dynamic, dynamic> {
'name': name,
'latitude': location.latitude,
'longitude': location.longitude,
'experience': yrsExp,
'charge' : price,
'imgUrl': imgUrl,
'email': email,
'description': description,
'trainingCert': trainingCert,
'firstAid': firstaid,
'matches': matches?.toList()
};
factory Walker.fromJson(Map<dynamic, dynamic> json) {
Set matches = {};
if (json['matches'] != null && json['matches'].isNotEmpty) {
matches = json['matches'];
}
return Walker(
name: json['name'] as String,
location: Location(latitude: double.parse(json['latitude']), longitude: double.parse(json['longitude'])),
yrsExp: int.parse(json['experience']),
price: double.parse(json['charge']),
imgUrl: json['imgUrl'] as String,
email: json['email'] as String,
description: json['description'] as String,
trainingCert: (json['trainingCert'] == 'true') ? true : false,
firstaid: (json['firstaid'] == 'true') ? true : false,
matches: matches
);
}
}