Search code examples
flutterfirebase-analytics

The class 'FirebaseAnalytics' doesn't have an unnamed constructor


I would like to use firebase analytics but keep getting this error, I upgrade and cleaned but still has the same error. any idea how I can solve it? thanks

static FirebaseAnalytics analytics = FirebaseAnalytics(); FirebaseAnalytics is underlined


Solution

  • I solve it by removing the parentheses and adding .instance.

    static FirebaseAnalytics analytics = FirebaseAnalytics.instance;

    see documentation. Thanks