Skip to content

[all plugins] All plugins should have a static instance member, and a static instanceFor() method if arguments are allowed #1377

@collinjackson

Description

@collinjackson

This is a breaking change that we'd like to land as part of our push towards stabilizing the Flutterfire API and authoring integration tests that work across web and mobile (see #40).

Currently the Flutterfire plugins are inconsistent about how you get an instance of the plugin. Some, like firebase_analytics, offer only an anonymous constructor: FirebaseAnalytics(). Others have a static final instance member. Some, like cloud_firestore, have both. The anonymous constructor sometimes takes additional arguments, as in the case of firebase_storage.

The following change is proposed:

  • All plugins (except core) should have a FirebaseXXX.instance member that uses the default Firebase app.
  • If the plugin offers optional named constructor arguments such as multiple app support, a FirebaseXXX.instanceFor() factory constructor should be provided.
  • The method should return the same instance when passed identical arguments.
  • Anonymous constructors should be deprecated and removed in a subsequent release.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions