56 lines
1.7 KiB
Dart
56 lines
1.7 KiB
Dart
import 'package:hiddingsel_app/appflow/model/interfaces.dart';
|
|
import 'package:hiddingsel_app/appflow/model/location.dart';
|
|
|
|
class ContactModel with IsSearchable{
|
|
final String? phone;
|
|
final String? mail;
|
|
final LocationModel? location;
|
|
final Uri? website;
|
|
final String? facebook;
|
|
final String? instagram;
|
|
final String? twitter;
|
|
get tags => [phone, mail, location?.address, website?.host, facebook, instagram].where((e) => e != null).toList();
|
|
|
|
const ContactModel(
|
|
{this.phone,
|
|
this.mail,
|
|
this.location,
|
|
this.website,
|
|
this.facebook,
|
|
this.instagram,
|
|
this.twitter
|
|
});
|
|
|
|
factory ContactModel.fromJson(Map<String, dynamic> json) {
|
|
return ContactModel(
|
|
phone: (json['phone'] as String?) != null ? json['phone'] as String: null,
|
|
mail: (json['mail'] as String?) != null ? json['mail'] as String: null,
|
|
location: (json['location'] as Map<String, dynamic>?) != null
|
|
? LocationModel.fromJson(json['location'] as Map<String, dynamic>)
|
|
: null,
|
|
website: (json['website'] as String?) != null
|
|
? Uri.parse(json['website'] as String)
|
|
: null,
|
|
facebook: (json['facebook'] as String?) != null
|
|
? json['facebook'] as String
|
|
: null,
|
|
instagram: (json['instagram'] as String?) != null
|
|
? json['instagram'] as String
|
|
: null,
|
|
twitter: (json['twitter'] as String?) != null
|
|
? json['twitter'] as String
|
|
: null,
|
|
);
|
|
}
|
|
|
|
toJson() =>{
|
|
'phone': phone,
|
|
'mail': mail,
|
|
'location': location?.toJson(),
|
|
'website': website?.toString(),
|
|
'facebook': facebook,
|
|
'instagram': instagram,
|
|
'twitter': twitter,
|
|
};
|
|
}
|