import 'package:autos/domain/entities/product.dart'; class ProductModel extends ProductEntity { ProductModel({ required super.id, required super.name, required super.image, required super.price, }); factory ProductModel.fromJson(Map json) { return ProductModel( id: json['id'] ?? 0, /// ✅ SAFE STRING CONVERSION name: json['name']?.toString() ?? '', /// ✅ API sends `logo`, but entity expects `image` image: json['logo']?.toString() ?? '', /// ✅ API DOES NOT SEND PRICE → DEFAULT TO 0 price: json['price'] != null ? double.tryParse(json['price'].toString()) ?? 0.0 : 0.0, ); } }