Skip to content

Introduce enablePersistenceForWeb() to avoid deprecated method on web #13290

Open
@guplem

Description

@guplem

Description:
I'm using cloud_firestore: ^5.4.0 and Flutter stable channel 3.24.2, and I have encountered an issue where the enablePersistence() method is marked as deprecated, but it is still required for web-based Flutter apps.

Issue:

  • The method enablePersistence() is marked as deprecated in the latest version of cloud_firestore.
  • However, as per the official documentation, it is still necessary to use this method to enable offline persistence for web.
  • There is currently no alternative approach for enabling persistence on web platforms. Using a deprecated method can cause confusion, especially since Settings.persistenceEnabled only works for non-web platforms.

Suggestion:

Ideally, web should follow the same persistence system as the rest of the platforms. But until that is feasible, a dedicated method like enablePersistenceForWeb() should be introduced to:

  1. Avoid using a deprecated method on web.
  2. Clearly differentiate web-specific persistence behavior.
  3. Prevent confusion and the need for developers to use // ignore: deprecated_member_use, which would hide the moment when web persistence truly becomes deprecated with this method.

Using // ignore: deprecated_member_use forces web developers to ignore the deprecation warning, making it difficult to know when the proper system for web has been implemented and when the method should no longer be used.

Steps to Reproduce:

  1. Use cloud_firestore: ^5.4.0 in a Flutter app targeting web.
  2. Attempt to implement offline persistence using Settings.persistenceEnabled.
  3. Observe that the method is deprecated but still required for web, leading to confusion.

Expected Behavior:

  • Either a dedicated method (enablePersistenceForWeb()) should be introduced, or the deprecation should be removed for web-based usage.
  • Web developers should have a clear and non-deprecated method to enable offline persistence until web can share the same persistence system as other platforms.

This approach would enhance clarity, prevent misuse of deprecated methods, and help web developers anticipate the proper transition when the persistence system is unified across platforms.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions