class TabData { String id; String title; String url; String favicon; DateTime lastAccessed; bool isPinned; String type; int? visitCount; String? folder; TabData({ required this.id, required this.title, required this.url, this.favicon = '', DateTime? lastAccessed, this.isPinned = false, this.type = 'tab', this.visitCount, this.folder, }) : lastAccessed = lastAccessed ?? DateTime.now(); factory TabData.fromJson(Map json) => TabData( 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'], ); } // This is our data model that represents a single tab, bookmark, or history item. // // It holds all the information we need about each item: title, URL, favicon, when it was accessed, etc. // // Think of it as a blueprint or template for storing browser item information. // // Every tab, bookmark, or history entry in our app is stored as a TabData object. // // The constructor creates new TabData objects with required fields like id, title, and url. // // Optional fields have default values, like favicon defaults to empty string and isPinned defaults to false. // // The fromJson factory method converts JSON data from the browser API into a TabData object. // // It handles different date field names from different sources like lastAccessed, lastVisitTime, dateAdded, or timestamp. // // It also handles missing data gracefully by using default values with the ?? operator. // // This class is the foundation of our app since everything revolves around displaying and managing these items.