import 'dart:convert'; import 'package:drift/drift.dart'; import '../../models/user_profile.dart'; import 'app_database.dart'; UserProfile profileFromRow(UserProfileRow row) { return UserProfile( firebaseUid: row.firebaseUid, email: row.email, displayName: row.displayName, photoUrl: row.photoUrl, locale: row.locale, timezone: row.timezone, onboardingCompleted: row.onboardingCompleted, revision: row.revision, updatedAt: row.updatedAt.toUtc(), lastSyncedAt: row.lastSyncedAt?.toUtc(), dirty: row.dirty, ); } UserProfileRowsCompanion companionFromProfile(UserProfile profile) { return UserProfileRowsCompanion( firebaseUid: Value(profile.firebaseUid), email: Value(profile.email), displayName: Value(profile.displayName), photoUrl: Value(profile.photoUrl), locale: Value(profile.locale), timezone: Value(profile.timezone), onboardingCompleted: Value(profile.onboardingCompleted), revision: Value(profile.revision), updatedAt: Value(profile.updatedAt.toUtc()), lastSyncedAt: Value(profile.lastSyncedAt?.toUtc()), dirty: Value(profile.dirty), ); } String encodeProfilePayload(UserProfile profile) { return jsonEncode(profile.toJson()); } UserProfile decodeProfilePayload(String json) { return UserProfile.fromJson( jsonDecode(json) as Map, ); }