flutterfire icon indicating copy to clipboard operation
flutterfire copied to clipboard

[firebase_analytics_web] throws TypeError: dart.global.firebase.analytics is not a function

Open VishnuSuresh2000 opened this issue 6 years ago β€’ 19 comments

How to resolve this firebase error . this error is showing only on running in web

TypeError: dart.global.firebase.analytics is not a function
    at Object.analytics$ [as analytics] (http://localhost:5000/packages/firebase/src/top_level.dart.lib.js:110:102)
    at new firebase_analytics_web.FirebaseAnalyticsWeb.new (http://localhost:5000/packages/firebase_analytics_web/firebase_analytics_web.dart.lib.js:56:64)
    at Function.registerWith (http://localhost:5000/packages/firebase_analytics_web/firebase_analytics_web.dart.lib.js:19:82)
    at Object.registerPlugins (http://localhost:5000/packages/beru/generated_plugin_registrant.dart.lib.js:20:49)
    at main (http://localhost:5000/web_entrypoint.dart.lib.js:29:35)
    at main.next (<anonymous>)
    at runBody (http://localhost:5000/dart_sdk.js:37623:34)
    at Object._async [as async] (http://localhost:5000/dart_sdk.js:37654:7)
    at main$ (http://localhost:5000/web_entrypoint.dart.lib.js:28:18)
    at http://localhost:5000/main_module.bootstrap.js:20:10
    at Array.forEach (<anonymous>)
    at window.$dartRunMain (http://localhost:5000/main_module.bootstrap.js:19:32)
    at <anonymous>:1:8
    at Object.runMain (http://localhost:5000/dwds/src/injected/client.js:8758:21)
    at http://localhost:5000/dwds/src/injected/client.js:22459:19
    at _wrapJsFunctionForAsync_closure.$protected (http://localhost:5000/dwds/src/injected/client.js:3802:15)
    at _wrapJsFunctionForAsync_closure.call$2 (http://localhost:5000/dwds/src/injected/client.js:10996:12)
    at Object._asyncStartSync (http://localhost:5000/dwds/src/injected/client.js:3766:20)
    at main__closure1.$call$body$main__closure (http://localhost:5000/dwds/src/injected/client.js:22471:16)
    at main__closure1.call$1 (http://localhost:5000/dwds/src/injected/client.js:22398:19)
    at StaticClosure._rootRunUnary [as call$2$5] (http://localhost:5000/dwds/src/injected/client.js:4136:16)
    at _CustomZone.runUnary$2$2 (http://localhost:5000/dwds/src/injected/client.js:12301:39)
    at _CustomZone.runUnaryGuarded$1$2 (http://localhost:5000/dwds/src/injected/client.js:12233:14)
    at _ControllerSubscription._sendData$1 (http://localhost:5000/dwds/src/injected/client.js:11784:19)
    at _DelayedData.perform$1 (http://localhost:5000/dwds/src/injected/client.js:11936:59)
    at _PendingEvents_schedule_closure.call$0 (http://localhost:5000/dwds/src/injected/client.js:11985:14)
    at Object._microtaskLoop (http://localhost:5000/dwds/src/injected/client.js:3969:24)
    at StaticClosure._startMicrotaskLoop (http://localhost:5000/dwds/src/injected/client.js:3975:11)
    at _AsyncRun__initializeScheduleImmediate_internalCallback.call$1 (http://localhost:5000/dwds/src/injected/client.js:10865:9)
    at invokeClosure (http://localhost:5000/dwds/src/injected/client.js:1204:26)
    at invokeClosure (http://localhost:5000/dwds/src/injected/client.js:1204:26)

index.html firebase section

<script src="https://www.gstatic.com/firebasejs/7.19.1/firebase-app.js"></script>
  <script defer src="https://www.gstatic.com/firebasejs/7.19.1/firebase-auth.js"></script>
  <!-- TODO: Add SDKs for Firebase products that you want to use
     https://firebase.google.com/docs/web/setup#available-libraries -->
  <script src="https://www.gstatic.com/firebasejs/7.19.1/firebase-analytics.js"></script>

  <script>
    // Your web app's Firebase configuration
    var firebaseConfig = {
      apiKey: "A....",
      authDomain: "....",
      databaseURL: "......,
      projectId: "....",
      storageBucket: "....",
      messagingSenderId: "...",
      appId: ".....",
      measurementId: "...."
    };
    // Initialize Firebase
    firebase.initializeApp(firebaseConfig);
    // firebase.analytics();
  </script>

Same error while initialized the firebase.analytics()

<script src="https://www.gstatic.com/firebasejs/7.19.1/firebase-app.js"></script>
  <script defer src="https://www.gstatic.com/firebasejs/7.19.1/firebase-auth.js"></script>
  <!-- TODO: Add SDKs for Firebase products that you want to use
     https://firebase.google.com/docs/web/setup#available-libraries -->
  <script src="https://www.gstatic.com/firebasejs/7.19.1/firebase-analytics.js"></script>

  <script>
    // Your web app's Firebase configuration
    var firebaseConfig = {
      apiKey: "A....",
      authDomain: "....",
      databaseURL: "......,
      projectId: "....",
      storageBucket: "....",
      messagingSenderId: "...",
      appId: ".....",
      measurementId: "...."
    };
    // Initialize Firebase
    firebase.initializeApp(firebaseConfig);
    firebase.analytics();
  </script>

flutter doctor :

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel beta, 1.21.0-9.2.pre, on Microsoft Windows [Version 10.0.19041.450], locale en-IN)
 
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.0)
[X] Chrome - develop for the web (Cannot find Chrome executable at .\Google\Chrome\Application\chrome.exe)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[√] Android Studio (version 4.0)
[√] VS Code, 64-bit edition (version 1.48.2)
[√] Connected device (2 available)  

! Doctor found issues in 1 category

The pubspec.yaml added the dependency

styled_text: ^1.0.1+1
  firebase_core: ^0.5.0
  firebase_analytics: "^6.0.0"
  carousel_pro: ^1.0.0

when don't declare the firebase_analytics there is no error and web is ruining

styled_text: ^1.0.1+1
  firebase_core: ^0.5.0
  #firebase_analytics: "^6.0.0"
  carousel_pro: ^1.0.0

VishnuSuresh2000 avatar Aug 31 '20 09:08 VishnuSuresh2000

I have the same problem, but in my case only if I build in release mode

alejandroaap avatar Aug 31 '20 11:08 alejandroaap

I have the same error.

enzodanjour avatar Aug 31 '20 19:08 enzodanjour

Hi @VishnuSuresh2000 Just tried on debug and release mode on the web

Screenshot 2020-09-01 at 5 29 03 PM
code sample
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:async';

import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:firebase_analytics/firebase_analytics.dart';
import 'package:firebase_analytics/observer.dart';

import 'tabs_page.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  FirebaseApp app = await Firebase.initializeApp();
  assert(app != null);
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  static FirebaseAnalytics analytics = FirebaseAnalytics();
  static FirebaseAnalyticsObserver observer =
      FirebaseAnalyticsObserver(analytics: analytics);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Firebase Analytics Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      navigatorObservers: <NavigatorObserver>[observer],
      home: MyHomePage(
        title: 'Firebase Analytics Demo',
        analytics: analytics,
        observer: observer,
      ),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title, this.analytics, this.observer})
      : super(key: key);

  final String title;
  final FirebaseAnalytics analytics;
  final FirebaseAnalyticsObserver observer;

  @override
  _MyHomePageState createState() => _MyHomePageState(analytics, observer);
}

class _MyHomePageState extends State<MyHomePage> {
  _MyHomePageState(this.analytics, this.observer);

  final FirebaseAnalyticsObserver observer;
  final FirebaseAnalytics analytics;
  String _message = '';

  void setMessage(String message) {
    setState(() {
      _message = message;
    });
  }

  Future<void> _sendAnalyticsEvent() async {
    await analytics.logEvent(
      name: 'test_event',
      parameters: <String, dynamic>{
        'string': 'string',
        'int': 42,
        'long': 12345678910,
        'double': 42.0,
        'bool': true,
      },
    );
    setMessage('logEvent succeeded');
  }

  Future<void> _testSetUserId() async {
    await analytics.setUserId('some-user');
    setMessage('setUserId succeeded');
  }

  Future<void> _testSetCurrentScreen() async {
    await analytics.setCurrentScreen(
      screenName: 'Analytics Demo',
      screenClassOverride: 'AnalyticsDemo',
    );
    setMessage('setCurrentScreen succeeded');
  }

  Future<void> _testSetAnalyticsCollectionEnabled() async {
    await analytics.setAnalyticsCollectionEnabled(false);
    await analytics.setAnalyticsCollectionEnabled(true);
    setMessage('setAnalyticsCollectionEnabled succeeded');
  }

  Future<void> _testSetSessionTimeoutDuration() async {
    await analytics.android?.setSessionTimeoutDuration(2000000);
    setMessage('setSessionTimeoutDuration succeeded');
  }

  Future<void> _testSetUserProperty() async {
    await analytics.setUserProperty(name: 'regular', value: 'indeed');
    setMessage('setUserProperty succeeded');
  }

  Future<void> _testAllEventTypes() async {
    await analytics.logAddPaymentInfo();
    await analytics.logAddToCart(
      currency: 'USD',
      value: 123.0,
      itemId: 'test item id',
      itemName: 'test item name',
      itemCategory: 'test item category',
      quantity: 5,
      price: 24.0,
      origin: 'test origin',
      itemLocationId: 'test location id',
      destination: 'test destination',
      startDate: '2015-09-14',
      endDate: '2015-09-17',
    );
    await analytics.logAddToWishlist(
      itemId: 'test item id',
      itemName: 'test item name',
      itemCategory: 'test item category',
      quantity: 5,
      price: 24.0,
      value: 123.0,
      currency: 'USD',
      itemLocationId: 'test location id',
    );
    await analytics.logAppOpen();
    await analytics.logBeginCheckout(
      value: 123.0,
      currency: 'USD',
      transactionId: 'test tx id',
      numberOfNights: 2,
      numberOfRooms: 3,
      numberOfPassengers: 4,
      origin: 'test origin',
      destination: 'test destination',
      startDate: '2015-09-14',
      endDate: '2015-09-17',
      travelClass: 'test travel class',
    );
    await analytics.logCampaignDetails(
      source: 'test source',
      medium: 'test medium',
      campaign: 'test campaign',
      term: 'test term',
      content: 'test content',
      aclid: 'test aclid',
      cp1: 'test cp1',
    );
    await analytics.logEarnVirtualCurrency(
      virtualCurrencyName: 'bitcoin',
      value: 345.66,
    );
    await analytics.logEcommercePurchase(
      currency: 'USD',
      value: 432.45,
      transactionId: 'test tx id',
      tax: 3.45,
      shipping: 5.67,
      coupon: 'test coupon',
      location: 'test location',
      numberOfNights: 3,
      numberOfRooms: 4,
      numberOfPassengers: 5,
      origin: 'test origin',
      destination: 'test destination',
      startDate: '2015-09-13',
      endDate: '2015-09-14',
      travelClass: 'test travel class',
    );
    await analytics.logGenerateLead(
      currency: 'USD',
      value: 123.45,
    );
    await analytics.logJoinGroup(
      groupId: 'test group id',
    );
    await analytics.logLevelUp(
      level: 5,
      character: 'witch doctor',
    );
    await analytics.logLogin();
    await analytics.logPostScore(
      score: 1000000,
      level: 70,
      character: 'tiefling cleric',
    );
    await analytics.logPresentOffer(
      itemId: 'test item id',
      itemName: 'test item name',
      itemCategory: 'test item category',
      quantity: 6,
      price: 3.45,
      value: 67.8,
      currency: 'USD',
      itemLocationId: 'test item location id',
    );
    await analytics.logPurchaseRefund(
      currency: 'USD',
      value: 45.67,
      transactionId: 'test tx id',
    );
    await analytics.logSearch(
      searchTerm: 'hotel',
      numberOfNights: 2,
      numberOfRooms: 1,
      numberOfPassengers: 3,
      origin: 'test origin',
      destination: 'test destination',
      startDate: '2015-09-14',
      endDate: '2015-09-16',
      travelClass: 'test travel class',
    );
    await analytics.logSelectContent(
      contentType: 'test content type',
      itemId: 'test item id',
    );
    await analytics.logShare(
        contentType: 'test content type',
        itemId: 'test item id',
        method: 'facebook');
    await analytics.logSignUp(
      signUpMethod: 'test sign up method',
    );
    await analytics.logSpendVirtualCurrency(
      itemName: 'test item name',
      virtualCurrencyName: 'bitcoin',
      value: 34,
    );
    await analytics.logTutorialBegin();
    await analytics.logTutorialComplete();
    await analytics.logUnlockAchievement(id: 'all Firebase API covered');
    await analytics.logViewItem(
      itemId: 'test item id',
      itemName: 'test item name',
      itemCategory: 'test item category',
      itemLocationId: 'test item location id',
      price: 3.45,
      quantity: 6,
      currency: 'USD',
      value: 67.8,
      flightNumber: 'test flight number',
      numberOfPassengers: 3,
      numberOfRooms: 1,
      numberOfNights: 2,
      origin: 'test origin',
      destination: 'test destination',
      startDate: '2015-09-14',
      endDate: '2015-09-15',
      searchTerm: 'test search term',
      travelClass: 'test travel class',
    );
    await analytics.logViewItemList(
      itemCategory: 'test item category',
    );
    await analytics.logViewSearchResults(
      searchTerm: 'test search term',
    );
    setMessage('All standard events logged successfully');
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Column(
        children: <Widget>[
          MaterialButton(
            child: const Text('Test logEvent'),
            onPressed: _sendAnalyticsEvent,
          ),
          MaterialButton(
            child: const Text('Test standard event types'),
            onPressed: _testAllEventTypes,
          ),
          MaterialButton(
            child: const Text('Test setUserId'),
            onPressed: _testSetUserId,
          ),
          MaterialButton(
            child: const Text('Test setCurrentScreen'),
            onPressed: _testSetCurrentScreen,
          ),
          MaterialButton(
            child: const Text('Test setAnalyticsCollectionEnabled'),
            onPressed: _testSetAnalyticsCollectionEnabled,
          ),
          MaterialButton(
            child: const Text('Test setSessionTimeoutDuration'),
            onPressed: _testSetSessionTimeoutDuration,
          ),
          MaterialButton(
            child: const Text('Test setUserProperty'),
            onPressed: _testSetUserProperty,
          ),
          Text(_message,
              style: const TextStyle(color: Color.fromARGB(255, 0, 155, 0))),
        ],
      ),
      floatingActionButton: FloatingActionButton(
          child: const Icon(Icons.tab),
          onPressed: () {
            Navigator.of(context).push(MaterialPageRoute<TabsPage>(
                settings: const RouteSettings(name: TabsPage.routeName),
                builder: (BuildContext context) {
                  return TabsPage(observer);
                }));
          }),
    );
  }
}

       <script src="https://www.gstatic.com/firebasejs/7.19.1/firebase-app.js"></script>
       <script src="https://www.gstatic.com/firebasejs/7.19.1/firebase-analytics.js"></script>
Launching lib/main.dart on Chrome in release mode...
Compiling lib/main.dart for the Web...                             22.2s

Warning: Flutter's support for web development is not stable yet and hasn't
been thoroughly tested in production environments.
For more information see https://flutter.dev/web

πŸ”₯  To hot restart changes while running, press "r" or "R".
For a more detailed help message, press "h". To quit, press "q".


flutter doctor -v
[βœ“] Flutter (Channel beta, 1.21.0-9.2.pre, on Mac OS X 10.15.6 19G2021, locale
    en-GB)
    β€’ Flutter version 1.21.0-9.2.pre at /Users/tahatesser/Code/flutter_beta
    β€’ Framework revision 81a45ec2e5 (5 days ago), 2020-08-27 14:14:33 -0700
    β€’ Engine revision 20a9531835
    β€’ Dart version 2.10.0 (build 2.10.0-7.3.beta)

 
[βœ“] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    β€’ Android SDK at /Users/tahatesser/Code/sdk
    β€’ Platform android-29, build-tools 29.0.2
    β€’ ANDROID_HOME = /Users/tahatesser/Code/sdk
    β€’ Java binary at: /Applications/Android
      Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    β€’ Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6222593)
    β€’ All Android licenses accepted.

[βœ“] Xcode - develop for iOS and macOS (Xcode 11.6)
    β€’ Xcode at /Applications/Xcode.app/Contents/Developer
    β€’ Xcode 11.6, Build version 11E708
    β€’ CocoaPods version 1.9.3

[βœ“] Chrome - develop for the web
    β€’ Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[βœ“] Android Studio (version 4.0)
    β€’ Android Studio at /Applications/Android Studio.app/Contents
    β€’ Flutter plugin version 48.1.2
    β€’ Dart plugin version 193.7547
    β€’ Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6222593)

[βœ“] VS Code (version 1.48.2)
    β€’ VS Code at /Applications/Visual Studio Code.app/Contents
    β€’ Flutter extension version 3.13.2

[βœ“] Connected device (3 available)
    β€’ Taha’s iPhone (mobile) β€’ 00008020-001059882212002E β€’ ios            β€’ iOS
      13.6.1
    β€’ Web Server (web)       β€’ web-server                β€’ web-javascript β€’
      Flutter Tools
    β€’ Chrome (web)           β€’ chrome                    β€’ web-javascript β€’
      Google Chrome 84.0.4147.135

β€’ No issues found!

Can you please provide flutter run -d chrome --release --verbose logs, and a minimal complete reproducible code sample Thank you

TahaTesser avatar Sep 01 '20 12:09 TahaTesser

Now i don't get any error from that web is running fine in this command flutter run -d chrome --release --verbose

But got error on debug mode in vs code on Web Server,

Launching lib\main.dart on Web Server in debug mode...
Waiting for connection from Dart debug extension at http://localhost:5000
The web-server device requires the Dart Debug Chrome extension for debugging. Consider using the Chrome or Edge devices for an improved development workflow.
Debug service listening on ws://127.0.0.1:61367/m8Yg8v41_yk=
Connecting to VM Service at ws://127.0.0.1:61367/m8Yg8v41_yk=
TypeError: dart.global.firebase.analytics is not a function
    at Object.analytics$ [as analytics] (http://localhost:5000/packages/firebase/src/top_level.dart.lib.js:110:102)
    at new firebase_analytics_web.FirebaseAnalyticsWeb.new (http://localhost:5000/packages/firebase_analytics_web/firebase_analytics_web.dart.lib.js:56:64)
    at Function.registerWith (http://localhost:5000/packages/firebase_analytics_web/firebase_analytics_web.dart.lib.js:19:82)
    at Object.registerPlugins (http://localhost:5000/packages/beru/generated_plugin_registrant.dart.lib.js:20:49)
    at main (http://localhost:5000/web_entrypoint.dart.lib.js:29:35)
    at main.next (<anonymous>)
    at runBody (http://localhost:5000/dart_sdk.js:37623:34)
    at Object._async [as async] (http://localhost:5000/dart_sdk.js:37654:7)
    at main$ (http://localhost:5000/web_entrypoint.dart.lib.js:28:18)
    at http://localhost:5000/main_module.bootstrap.js:20:10
    at Array.forEach (<anonymous>)
    at window.$dartRunMain (http://localhost:5000/main_module.bootstrap.js:19:32)
    at <anonymous>:1:8
    at Object.runMain (http://localhost:5000/dwds/src/injected/client.js:8758:21)
    at http://localhost:5000/dwds/src/injected/client.js:22459:19
    at _wrapJsFunctionForAsync_closure.$protected (http://localhost:5000/dwds/src/injected/client.js:3802:15)
    at _wrapJsFunctionForAsync_closure.call$2 (http://localhost:5000/dwds/src/injected/client.js:10996:12)
    at Object._asyncStartSync (http://localhost:5000/dwds/src/injected/client.js:3766:20)
    at main__closure1.$call$body$main__closure (http://localhost:5000/dwds/src/injected/client.js:22471:16)
    at main__closure1.call$1 (http://localhost:5000/dwds/src/injected/client.js:22398:19)
    at StaticClosure._rootRunUnary [as call$2$5] (http://localhost:5000/dwds/src/injected/client.js:4136:16)
    at _CustomZone.runUnary$2$2 (http://localhost:5000/dwds/src/injected/client.js:12301:39)
    at _CustomZone.runUnaryGuarded$1$2 (http://localhost:5000/dwds/src/injected/client.js:12233:14)
    at _ControllerSubscription._sendData$1 (http://localhost:5000/dwds/src/injected/client.js:11784:19)
    at _DelayedData.perform$1 (http://localhost:5000/dwds/src/injected/client.js:11936:59)
    at _PendingEvents_schedule_closure.call$0 (http://localhost:5000/dwds/src/injected/client.js:11985:14)
    at Object._microtaskLoop (http://localhost:5000/dwds/src/injected/client.js:3969:24)
    at StaticClosure._startMicrotaskLoop (http://localhost:5000/dwds/src/injected/client.js:3975:11)
    at _AsyncRun__initializeScheduleImmediate_internalCallback.call$1 (http://localhost:5000/dwds/src/injected/client.js:10865:9)
    at invokeClosure (http://localhost:5000/dwds/src/injected/client.js:1204:26)

But got error on debug mode in vs code on Edge,

Launching lib\main.dart on Edge in debug mode...
Debug service listening on ws://127.0.0.1:61498/jbMgvL915Zo=
Connecting to VM Service at ws://127.0.0.1:61498/jbMgvL915Zo=
WS chnnel ws://localhost:80
WS init controller
Server Url true http://localhost:80
called firbase init in autoUserStatusCheck
called firbase init in autoUserStatusCheck
User Status firebase null server null address null
User Status firebase null server null address null
TypeError: dart.global.firebase.auth is not a function
    at Object.auth$ [as auth] (http://localhost:5000/packages/firebase/src/top_level.dart.lib.js:82:55)
    at new firebase_auth_web.FirebaseAuthWeb.new (http://localhost:5000/packages/firebase_auth_web/firebase_auth_web.dart.lib.js:267:32)
    at firebase_auth_web.FirebaseAuthWeb.__.delegateFor (http://localhost:5000/packages/firebase_auth_web/firebase_auth_web.dart.lib.js:58:14)
    at Function.instanceFor (http://localhost:5000/packages/firebase_auth_platform_interface/src/providers/twitter_auth.dart.lib.js:1305:77)
    at firebase_auth.FirebaseAuth.__.get [_delegate] (http://localhost:5000/packages/firebase_auth/firebase_auth.dart.lib.js:71:96)
    at firebase_auth.FirebaseAuth.__.authStateChanges (http://localhost:5000/packages/firebase_auth/firebase_auth.dart.lib.js:164:43)
    at userProvider.UserState.new.autoUserStatusCheck (http://localhost:5000/packages/beru/BLOC/CustomProviders/userProvider.dart.lib.js:135:71)
    at autoUserStatusCheck.next (<anonymous>)
    at runBody (http://localhost:5000/dart_sdk.js:37623:34)
    at Object._async [as async] (http://localhost:5000/dart_sdk.js:37654:7)
    at userProvider.UserState.new.autoUserStatusCheck (http://localhost:5000/packages/beru/BLOC/CustomProviders/userProvider.dart.lib.js:134:20)
    at new userProvider.UserState.new (http://localhost:5000/packages/beru/BLOC/CustomProviders/userProvider.dart.lib.js:349:10)
    at _CreateInheritedProvider.new.create (http://localhost:5000/packages/beru/BLOC/BlocList.dart.lib.js:278:123)
    at _CreateInheritedProviderState.new.get value [as value] (http://localhost:5000/packages/provider/src/provider.dart.lib.js:905:73)
    at _InheritedProviderScopeElement.new.get value [as value] (http://localhost:5000/packages/provider/src/provider.dart.lib.js:680:37)
    at Function.of (http://localhost:5000/packages/provider/src/provider.dart.lib.js:306:33)
    at Selector.new.<anonymous> (http://localhost:5000/packages/provider/src/selector.dart.lib.js:162:165)
    at _Selector0State.new.buildWithChild (http://localhost:5000/packages/provider/src/selector.dart.lib.js:113:60)
    at _Selector0State.new.build (http://localhost:5000/packages/nested/nested.dart.lib.js:413:21)
    at nested.SingleChildStatefulElement.new.build (http://localhost:5000/packages/flutter/src/widgets/widget_span.dart.lib.js:43716:29)
    at nested.SingleChildStatefulElement.new.build (http://localhost:5000/packages/nested/nested.dart.lib.js:449:20)
    at nested.SingleChildStatefulElement.new.performRebuild (http://localhost:5000/packages/flutter/src/widgets/widget_span.dart.lib.js:23672:22)
    at nested.SingleChildStatefulElement.new.performRebuild (http://localhost:5000/packages/flutter/src/widgets/widget_span.dart.lib.js:43755:13)
    at nested.SingleChildStatefulElement.new.rebuild (http://localhost:5000/packages/flutter/src/widgets/widget_span.dart.lib.js:22921:12)
    at nested.SingleChildStatefulElement.new.[_firstBuild] (http://localhost:5000/packages/flutter/src/widgets/widget_span.dart.lib.js:23661:12)
    at nested.SingleChildStatefulElement.new.[_firstBuild] (http://localhost:5000/packages/flutter/src/widgets/widget_span.dart.lib.js:43748:25)
    at nested.SingleChildStatefulElement.new.mount (http://localhost:5000/packages/flutter/src/widgets/widget_span.dart.lib.js:23657:24)
    at nested.SingleChildStatefulElement.new.mount (http://localhost:5000/packages/nested/nested.dart.lib.js:130:13)
    at framework.StatefulElement.new.inflateWidget (http://localhost:5000/packages/flutter/src/widgets/widget_span.dart.lib.js:22509:16)
    at framework.StatefulElement.new.updateChild (http://localhost:5000/packages/flutter/src/widgets/widget_span.dart.lib.js:22369:27)
    at framework.StatefulElement.new.performRebuild (http://localhost:5000/packages/flutter/src/widgets/widget_span.dart.lib.js:23690:29)
    at framework.StatefulElement.new.performRebuild (http://localhost:5000/packages/flutter/src/widgets/widget_span.dart.lib.js:43755:13)
    at framework.StatefulElement.new.rebuild (http://localhost:5000/packages/flutter/src/widgets/widget_span.dart.lib.js:22921:12)
    at framework.StatefulElement.new.update (http://localhost:5000/packages/flutter/src/widgets/widget_span.dart.lib.js:43776:12)
    at framework.StatefulElement.new.updateChild (http://localhost:5000/packages/flutter/src/widgets/widget_span.dart.lib.js:22359:17)
    at framework.StatefulElement.new.performRebuild (http://localhost:5000/packages/flutter/src/widgets/widget_span.dart.lib.js:23690:29)
    at framework.StatefulElement.new.performRebuild (http://localhost:5000/packages/flutter/src/widgets/widget_span.dart.lib.js:43755:13)
    at framework.StatefulElement.new.rebuild (http://localhost:5000/packages/flutter/src/widgets/widget_span.dart.lib.js:22921:12)
    at framework.BuildOwner.new.buildScope (http://localhost:5000/packages/flutter/src/widgets/widget_span.dart.lib.js:43380:48)
    at binding$5.WidgetsFlutterBinding.new.drawFrame (http://localhost:5000/packages/flutter/src/widgets/widget_span.dart.lib.js:45972:61)
    at binding$5.WidgetsFlutterBinding.new.[_handlePersistentFrameCallback] (http://localhost:5000/packages/flutter/src/rendering/layer.dart.lib.js:5702:12)
    at binding$5.WidgetsFlutterBinding.new.[_invokeFrameCallback] (http://localhost:5000/packages/flutter/src/scheduler/binding.dart.lib.js:756:9)
    at binding$5.WidgetsFlutterBinding.new.handleDrawFrame (http://localhost:5000/packages/flutter/src/scheduler/binding.dart.lib.js:724:37)
    at http://localhost:5000/packages/flutter/src/scheduler/binding.dart.lib.js:638:14
    at internalCallback (http://localhost:5000/dart_sdk.js:23778:11)[{"id":"3","result":{"result":null,"type":"","method":"ext.flutter.inspector.setPubRootDirectories"}}]

VishnuSuresh2000 avatar Sep 01 '20 14:09 VishnuSuresh2000

@TahaTesser Have you tried uploading the build / web folder to a server like firebase hosting? If you try to execute the result of the compilation of the app for the web on a web server you will see this error that the colleague is reporting, at least, in my case this is what happens

alejandroaap avatar Sep 01 '20 16:09 alejandroaap

Same issue was happened

VishnuSuresh2000 avatar Sep 01 '20 18:09 VishnuSuresh2000

I couldn't reproduce on Edge as well https://gifted-mcclintock-83b19b.netlify.app/#/

TahaTesser avatar Sep 02 '20 12:09 TahaTesser

Any solution other than removing firebase analytics?

alejandroaap avatar Sep 05 '20 07:09 alejandroaap

i just removed it

VishnuSuresh2000 avatar Sep 06 '20 05:09 VishnuSuresh2000

I couldn't reproduce on Edge as well https://gifted-mcclintock-83b19b.netlify.app/#/

That's strange, since your site returns as a blank page on my Firefox, Chrome, and Chromium. This error also occurs on my flutter web --release build.

blocked

flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[βœ“] Flutter (Channel beta, 1.21.0-9.2.pre, on Linux, locale en_US.UTF-8)
 
[βœ“] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[βœ“] Chrome - develop for the web
[βœ“] Android Studio (version 4.0)
[βœ“] Connected device (2 available)

β€’ No issues found!

function1983 avatar Sep 06 '20 11:09 function1983

So, the issue above was closed, but did they find a solution?

enzodanjour avatar Sep 23 '20 13:09 enzodanjour

Until this issue is resolved by Firebase team, we are using hack like that: Just after adding analytics script inside index.html we've added this:

<script>
// workaround for case when adblock blocks firebase analytics
    if (!firebase.analytics || !navigator.cookieEnabled) {
        firebase.analytics = function() {};
    }
</script>
It's enough for app to start.

miszmaniac avatar Sep 24 '20 19:09 miszmaniac

any solution? The problem keeps happening

alejandroaap avatar Oct 02 '20 20:10 alejandroaap

Until this issue is resolved by Firebase team, we are using hack like that: Just after adding analytics script inside index.html we've added this:

<script>
// workaround for case when adblock blocks firebase analytics
    if (!firebase.analytics || !navigator.cookieEnabled) {
        firebase.analytics = function() {};
    }
</script>
It's enough for app to start.

In case someone else is still in search of a solution/reason. Check that you don't have any tracking blockers running at the same time. Like adblock etc. In my case that was the cause for this error. (which works as intended in this case)

fourman-alex avatar Oct 07 '20 12:10 fourman-alex

I can't seem to get auth working, and am hitting this same error. I added the analytics check, but it's not helping. What's confusing is, it gives me this error: image

But that API call doesn't seem to exist, and it's not mentioned in the docs.

The exception seems to occur here: image image

esDotDev avatar Nov 25 '20 17:11 esDotDev

I had the same problem. I've updated my index.html file as indicated here: https://pub.dev/packages/firebase_analytics_web#update-indexhtml

and no more error :-)

sperochon avatar Mar 22 '21 11:03 sperochon

I had the same problem. I've updated my index.html file as indicated here: https://pub.dev/packages/firebase_analytics_web#update-indexhtml

and no more error :-)

Cheerio! Updating index.html fixed it for me.

jagadishnallappa avatar Jun 29 '21 16:06 jagadishnallappa

This looks like a problem with the environment as opposed to a problem with the package itself. i.e. adblock. If a reproducible example can be provided, will reopen.

russellwheatley avatar Jul 02 '21 14:07 russellwheatley

For me personally, the problem was with the order of <script src...s, reordering it like below fixed the issue.

<script src="https://www.gstatic.com/firebasejs/8.6.1/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.6.1/firebase-analytics.js"></script>

HosseinYousefi avatar Jul 20 '21 07:07 HosseinYousefi