DeviceInfo class
Represents a device registered with the DeviceService.
This model stores device-level information including timezone data,
push notification token, and activity tracking. Each device document
is stored at users/{uid}/devices/{deviceId} in Firestore.
Fields
- deviceId: Unique identifier for this device (UUIDv4, stable per install)
- timezone: IANA timezone string (e.g., "America/New_York")
- timezoneOffsetMinutes: Current UTC offset in minutes (updated for DST)
- lastActiveAt: Last time this device was active (for staleness tracking)
- fcmToken: Current push notification token (nullable when unavailable)
- fcmTokenUpdatedAt: When the token was last updated
- createdAt: When this device was first registered
- updatedAt: When this device document was last updated
- platform: Device platform (ios, android, web, macos, windows, linux)
- appVersion: App version installed on this device
- deviceInfo: Optional additional device metadata
Example
final device = DeviceInfo(
deviceId: '550e8400-e29b-41d4-a716-446655440000',
timezone: 'America/New_York',
timezoneOffsetMinutes: -300,
platform: DevicePlatform.ios,
appVersion: '1.2.3',
);
- Inheritance
-
- Object
- BaseFirestoreModel
- DeviceInfo
- Annotations
-
- @JsonSerializable.new(explicitToJson: true)
Constructors
- DeviceInfo({required String deviceId, required String timezone, required int timezoneOffsetMinutes, DateTime? lastActiveAt, String? fcmToken, DateTime? fcmTokenUpdatedAt, DateTime? createdAt, DateTime? updatedAt, DevicePlatform? platform, String? appVersion, DeviceMetadata? deviceInfo})
-
DeviceInfo.fromJson(Map<
String, dynamic> json) -
Creates a DeviceInfo from JSON data.
factory
Properties
- appVersion → String?
-
App version installed on this device.
final
- createdAt → DateTime?
-
When this device was first registered.
final
- deviceId → String
-
Unique identifier for this device (UUIDv4).
final
- deviceInfo → DeviceMetadata?
-
Additional device metadata.
final
- fcmToken → String?
-
Current FCM push notification token for this device.
final
- fcmTokenUpdatedAt → DateTime?
-
When fcmToken was last updated.
final
- hashCode → int
-
The hash code for this object.
no setteroverride
- lastActiveAt → DateTime?
-
When this device was last active.
final
- platform → DevicePlatform?
-
Device platform.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- timezone → String
-
IANA timezone identifier (e.g., "America/New_York", "Europe/London").
final
- timezoneOffsetMinutes → int
-
Current UTC offset in minutes.
final
- updatedAt → DateTime?
-
When this device document was last updated.
final
Methods
-
copyWith(
{String? deviceId, String? timezone, int? timezoneOffsetMinutes, DateTime? lastActiveAt, String? fcmToken, DateTime? fcmTokenUpdatedAt, DateTime? createdAt, DateTime? updatedAt, DevicePlatform? platform, String? appVersion, DeviceMetadata? deviceInfo}) → DeviceInfo - Creates a copy of this device info with the given fields replaced.
-
getCreateTimestampFields(
) → List< String> -
Fields that should only be set on document creation.
override
-
getUpdateTimestampFields(
) → List< String> -
Fields that should always be updated with server timestamp.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
postProcessJson(
Map< String, dynamic> json, SerializationContext context) → Map<String, dynamic> -
Override to add custom post-processing for specific models.
inherited
-
toCallable(
) → Map< String, dynamic> -
Convert for Firebase callable functions.
inherited
-
toFirestore(
{bool isUpdate = false}) → Map< String, dynamic> -
Legacy method for Firestore conversion.
inherited
-
toFirestoreCreate(
{bool useServerTimestamp = true, List< String> ? fieldsToExclude}) → Map<String, dynamic> -
Convert to Firestore document for CREATE operations.
inherited
-
toFirestoreRaw(
{List< String> ? fieldsToExclude}) → Map<String, dynamic> -
Convert to Firestore with explicit control (advanced use).
inherited
-
toFirestoreUpdate(
{List< String> ? fieldsToExclude}) → Map<String, dynamic> -
Convert to Firestore document for UPDATE operations.
inherited
-
toJson(
) → Map< String, dynamic> -
Converts this DeviceInfo to JSON data.
override
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override