-
-
Save marcossevilla/90a33b7c4274c2cebf33777582824b2d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:cloud_firestore/cloud_firestore.dart' show DocumentSnapshot; | |
import 'package:freezed_annotation/freezed_annotation.dart'; | |
part 'store_item.freezed.dart'; | |
part 'store_item.g.dart'; | |
@freezed | |
abstract class StoreItem with _$StoreItem { | |
const factory StoreItem.model({ | |
@required int id, | |
@required String name, | |
}) = StoreItemModel; | |
const factory StoreItem.firestore({ | |
@required int id, | |
@required String name, | |
@required bool isAvailable, | |
}) = StoreItemFirestore; | |
factory StoreItem.fromJson(Map<String, dynamic> json) => | |
_$StoreItemFromJson(json); | |
factory StoreItem.fromFirestore(DocumentSnapshot doc) { | |
return StoreItemFirestore.fromJson(doc.data()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment