Initial commit of Flutter project
This commit is contained in:
@@ -2,52 +2,74 @@ import 'package:hive/hive.dart';
|
||||
|
||||
part 'shop_model.g.dart';
|
||||
|
||||
@HiveType(typeId: 1)
|
||||
@HiveType(typeId: 0)
|
||||
class ShopModel {
|
||||
@HiveField(0)
|
||||
final String id;
|
||||
bool success;
|
||||
|
||||
@HiveField(1)
|
||||
final String image;
|
||||
ShopDetails user;
|
||||
|
||||
@HiveField(2)
|
||||
final String mobile;
|
||||
String token;
|
||||
|
||||
@HiveField(3)
|
||||
final String email;
|
||||
|
||||
@HiveField(4)
|
||||
final String shopName;
|
||||
|
||||
@HiveField(5)
|
||||
final String address; // ✅ NEW
|
||||
String message;
|
||||
|
||||
ShopModel({
|
||||
required this.id,
|
||||
required this.image,
|
||||
required this.mobile,
|
||||
required this.email,
|
||||
required this.shopName,
|
||||
required this.address,
|
||||
required this.success,
|
||||
required this.user,
|
||||
required this.token,
|
||||
required this.message,
|
||||
});
|
||||
|
||||
factory ShopModel.fromJson(Map<String, dynamic> json) {
|
||||
return ShopModel(
|
||||
id: json['id'] ?? '',
|
||||
image: json['image'] ?? '',
|
||||
mobile: json['mobile'] ?? '',
|
||||
email: json['email'] ?? '',
|
||||
shopName: json['shopName'] ?? '',
|
||||
address: json['address'] ?? '', // ✅ NEW
|
||||
);
|
||||
}
|
||||
factory ShopModel.fromJson(Map<String, dynamic> json) => ShopModel(
|
||||
success: json['success'],
|
||||
user: ShopDetails.fromJson(json['user']),
|
||||
token: json['token'],
|
||||
message: json['message'],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'success': success,
|
||||
'user': user.toJson(),
|
||||
'token': token,
|
||||
'message': message,
|
||||
};
|
||||
}
|
||||
|
||||
@HiveType(typeId: 1)
|
||||
class ShopDetails {
|
||||
@HiveField(0)
|
||||
String id;
|
||||
|
||||
@HiveField(1)
|
||||
String name;
|
||||
|
||||
@HiveField(2)
|
||||
String email;
|
||||
|
||||
@HiveField(3)
|
||||
String role;
|
||||
|
||||
ShopDetails({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.email,
|
||||
required this.role,
|
||||
});
|
||||
|
||||
factory ShopDetails.fromJson(Map<String, dynamic> json) => ShopDetails(
|
||||
id: json['id'],
|
||||
name: json['name'],
|
||||
email: json['email'],
|
||||
role: json['role'],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'image': image,
|
||||
'mobile': mobile,
|
||||
'name': name,
|
||||
'email': email,
|
||||
'shopName': shopName,
|
||||
'address': address, // ✅ NEW
|
||||
'role': role,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user