I hope someone could help me with this issue, I have tried all the examples given above, however the same error is still showing
Uncaught (in promise) FirebaseError: Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app/no-app).
at Object.f [as app] (https://www.gstatic.com/firebasejs/8.2.1/firebase-app.js:1:16867)
this my main.dart initial code
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
developer.log('${Firebase.apps.length}', name: 'main.dart');
FlutterError.onError = (FlutterErrorDetails details) {
FlutterError.dumpErrorToConsole(details);
};
runApp(App());
}
class App extends StatefulWidget {
_AppState createState() => _AppState();
}
class _AppState extends State<App> {
@override
Widget build(BuildContext context) {
if(Firebase.apps.length == 0){
return Loading();
}
else
return StreamProvider<UserData>.value(
value: AuthService().user,
child: MaterialApp(
title: MAIN_TITLE,
debugShowCheckedModeBanner: false,
theme: ThemeData(primarySwatch: Colors.amber, accentColor: Colors.amber[200]),
home: MyHomePage(
title: HOME_PAGE,
),
routes: <String, WidgetBuilder>{
'/home': (BuildContext context) => new Wrapper(),
},
),
);
}
}
This is my index.html file
<!DOCTYPE html>
<html>
<head>
<base href="/" />
<meta charset="UTF-8" />
<meta content="IE=Edge" http-equiv="X-UA-Compatible" />
<meta name="description" content="A new Flutter project." />
<!-- iOS meta tags & icons -->
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="apple-mobile-web-app-title" content="web_product_unitrade" />
<link rel="apple-touch-icon" href="icons/Icon-192.png" />
<!-- Favicon -->
<link rel="icon" type="image/png" href="favicon.png" />
<title>web_product_unitrade</title>
<link rel="manifest" href="manifest.json" />
</head>
<body>
<p id="error-element"></p>
<script src="https://www.gstatic.com/firebasejs/8.2.1/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.8.0/firebase-auth.js"></script>
<script type="module">
import { firebaseConfig} from '/lib/configuration/firebase-config.js';
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
firebase.analytics();
</script>
<script src="https://www.gstatic.com/firebasejs/8.2.1/firebase-analytics.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.17.1/firebase-firestore.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.2.1/firebase-storage.js"></script>
<script>
if ("serviceWorker" in navigator) {
window.addEventListener("flutter-first-frame", function () {
navigator.serviceWorker.register("flutter_service_worker.js");
});
}
</script>
<script src="main.dart.js" type="application/javascript"></script>
</body>
</html>
When running the app is runs properly locally, however when running in release mode, the following error is generated.
zone.dart:1171 Uncaught FirebaseError: Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app/no-app).
at Object.f [as app] (https://www.gstatic.com/firebasejs/8.2.1/firebase-app.js:1:16867)
at Object.afQ (http://localhost:52254/main.dart.js:9835:63)
at Object.ald (http://localhost:52254/main.dart.js:8221:29)
at http://localhost:52254/main.dart.js:14458:5
at afM.a (http://localhost:52254/main.dart.js:4531:71)
at afM.$2 (http://localhost:52254/main.dart.js:29996:23)
at Object.L (http://localhost:52254/main.dart.js:4517:19)
at Object.P9 (http://localhost:52254/main.dart.js:14482:10)
at http://localhost:52254/main.dart.js:71366:8
at http://localhost:52254/main.dart.js:71361:55
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…