// Class creating objects "Class Declaration" The Blueprint // ? means can be null or nothing "Operators" // ?? means if null, use this instead class TabData { // FIELDS for storing data "Fields" // What we will be uding in other parts of the code String id; String title; String url; String favicon; DateTime lastAccessed; bool isPinned; String type; int? visitCount; String? folder; // Constructor Declaration "Constructor Declaration" The Assembly Line TabData({ // Parameters saved from the data coming in // "this." current object required this.id, required this.title, required this.url, this.favicon = '', DateTime? lastAccessed, this.isPinned = false, this.type = 'tab', this.visitCount, this.folder, }) // initializer logic, AFTER parameters, BEFORE Constructor // ?? IF left is null, use right // left side is field, right side is parameter the new saved value : lastAccessed = lastAccessed ?? DateTime.now(); // factory logic before constructor, from json so we don't have to extract later. factory TabData.fromJson(Map json) => TabData( // Extract data pass to regular constructor id: json['id'].toString(), title: json['title'] ?? 'Untitled', url: json['url'] ?? '', favicon: json['favicon'] ?? json['favIconUrl'] ?? '', lastAccessed: json['lastAccessed'] != null ? DateTime.parse(json['lastAccessed']) : (json['lastVisitTime'] != null ? DateTime.parse(json['lastVisitTime']) : (json['dateAdded'] != null ? DateTime.parse(json['dateAdded']) : (json['timestamp'] != null ? DateTime.parse(json['timestamp']) : DateTime.now()))), isPinned: json['isPinned'] ?? false, type: json['type'] ?? 'tab', visitCount: json['visitCount'], folder: json['folder'], ); } // Data model single tab, bookmark, or history item. // // Blueprint storing browser item information. // // Every tab ,bookmark is stored as a TabData object. // // Constructor creates new TabData objects. // // Favicon defaults to empty string // // isPinned defaults to false. // // FromJson factory data browser API into TabData object. // // Missing data, default values ??. // // Foundation: managing/storing tabs.