Skip to content

Share/Unify Timestamp between google_cloud_firestore and cloud_firestore #286

Description

@mafreud

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions