I have a Flutter (iOS and Android) application for which I’m using Firebase RTDB and Auth for now. The mobile applications are not having any issues but I’m having issues configuring Web.
I’m getting an unusual error at the closing line of the last script tag.
localhost/:79 Uncaught SyntaxError: Unexpected end of input
Here is my index.html code which was generated when I ran flutter build web, I have not made any changes in the manifest.json file.
<!DOCTYPE html>
<html>
<head>
<base href="$FLUTTER_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="kidskommune_vendor">
<link rel="apple-touch-icon" href="icons/Icon-192.png">
<!-- Favicon -->
<link rel="icon" type="image/png" href="favicon.png"/>
<title>kidskommune_vendor</title>
<link rel="manifest" href="manifest.json">
<script>
// The value below is injected by flutter build, do not touch.
const serviceWorkerVersion = "{{flutter_service_worker_version}}";
</script>
<!-- This script adds the flutter initialization JS code -->
<script src="flutter.js" defer></script>
</head>
<body>
<script type="module">
import { initializeApp } from 'https://www.gstatic.com/firebasejs/10.12.4/firebase-app.js';
import { getAuth } from 'https://www.gstatic.com/firebasejs/10.12.4/firebase-auth.js';
import { getDatabase } from 'https://www.gstatic.com/firebasejs/10.12.4/firebase-database.js';
const firebaseConfig = {
apiKey: "",
authDomain: "..com",
databaseURL: "https://--.-.firebasedatabase.app",
projectId: "",
storageBucket: "..com",
messagingSenderId: "",
appId: "1::web:",
measurementId: "G-"
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const auth = getAuth(app);
const database = getDatabase(app);
auth.onAuthStateChanged(user => {
if (user) {
console.log("User is signed in:", user);
} else {
console.log("No user is signed in.");
}
});
</script>
<script>
window.addEventListener('load', function(ev) {
_flutter.loader.loadEntrypoint({
serviceWorker: {
serviceWorkerVersion: serviceWorkerVersion,
},
onEntrypointLoaded: async function(engineInitializer) {
// Initialize the Flutter engine
let appRunner = await engineInitializer.initializeEngine();
// Run the app
await appRunner.runApp();
}
});
</script>
</body>
</html>