import 'package:cloud_firestore/cloud_firestore.dart'; import 'inventory_line.dart'; class InventoryTaking { String accountID; String id; DateTime dateTime; String userID; String userName; List inventoryLines = []; bool linesLoaded = false; InventoryTaking( {this.accountID, this.id, this.userID, this.userName, this.dateTime}); factory InventoryTaking.fromMap(Map map, String id) { var _dateTime = (map['date_time'] as Timestamp); return InventoryTaking( id: id, accountID: map['account_id'], userID: map['user_id'], userName: map['user_name'], dateTime: _dateTime?.toDate(), ); } Map toMap() { List lines = inventoryLines.map((l) => l.toMap()).toList(); return { 'id': id, 'user_id': userID, 'user_name': userName, 'inventory_lines': lines, }; } @override String toString() { return 'InventoryTaking{id:$id,name:$userName}'; } }