You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Share/Unify Timestamp between google_cloud_firestore and cloud_firestore #286
Proposal: Share/Unify Timestamp between google_cloud_firestore and cloud_firestore
Problem
When building full-stack Dart applications (Flutter on the client, Dart VM/Firebase Functions on the server), sharing data models with Firestore timestamps is highly problematic.
cloud_firestore (specifically cloud_firestore_platform_interface) and google_cloud_firestore (firebase-admin-dart) define their own incompatible Timestamp classes.
Even though they have the same underlying structure (seconds and nanoseconds), Dart's static type system treats them as completely separate types.
As a result, shared models cannot run simple type checks (like value is Timestamp) without introducing Flutter dependencies to the backend. Developers must rely on brittle workarounds like string-based runtime type checking (value.runtimeType.toString().contains('Timestamp')).
Proposed Solution
We highly recommend extracting basic, pure Dart Firestore types (such as Timestamp and GeoPoint) into a lightweight, neutral package (e.g., firebase_common_types) with no dependencies on Flutter or VM-specific APIs.
Both cloud_firestore and google_cloud_firestore should then depend on and re-export these shared types. This will enable clean, type-safe full-stack Dart development.
My Flutter app uses cloud_firestore to fetch documents containing Timestamp values. These documents are then passed to models defined in a separate package that is shared between the app and my Firebase Functions.
That shared package cannot depend on cloud_firestore, since it is also used by the dart functions package, which doesn't support flutter packages. Instead, it depends on google_cloud_firestore and therefore expects google_cloud_firestore.Timestamp.
As a result, my TimestampConverter (defined in the shared models package) cannot recognize the Timestamp instances returned by cloud_firestore, even though cloud_firestore depends on google_cloud_firestore.
This makes me wonder: why doesn't cloud_firestore expose and use the Timestamp type from google_cloud_firestore directly?
I've run into similar, although less impactful, issues with duplicated definitions of GeoPoint and Filter.
@demolaf Is the team considering addressing this in the future? Shared model packages seem like a common use case now that Dart support for Firebase Functions is available.
Activity
demolaf commentedon Jun 4, 2026
Hi @mafreud , this does make a lot of sense. I will raise this with the team and keep this issue updated.
mafreud commentedon Jun 4, 2026
@demolaf Thank you as always!
ChreSyr commentedon Jun 24, 2026
I'm running into a similar issue with
Timestamp.My Flutter app uses
cloud_firestoreto fetch documents containingTimestampvalues. These documents are then passed to models defined in a separate package that is shared between the app and my Firebase Functions.That shared package cannot depend on
cloud_firestore, since it is also used by the dart functions package, which doesn't support flutter packages. Instead, it depends ongoogle_cloud_firestoreand therefore expectsgoogle_cloud_firestore.Timestamp.As a result, my
TimestampConverter(defined in the shared models package) cannot recognize theTimestampinstances returned bycloud_firestore, even thoughcloud_firestoredepends ongoogle_cloud_firestore.This makes me wonder: why doesn't
cloud_firestoreexpose and use theTimestamptype fromgoogle_cloud_firestoredirectly?I've run into similar, although less impactful, issues with duplicated definitions of
GeoPointandFilter.@demolaf Is the team considering addressing this in the future? Shared model packages seem like a common use case now that Dart support for Firebase Functions is available.
demolaf commentedon Jun 25, 2026
@ChreSyr Yes, this has been raised internally. I'll try to provide feedback once I have more details.