Flutter web app paused at web_entrypoint.dart
Asked Answered
C

2

12

I am new to flutter, I was trying to build a web app , and i am trying to save text data to firestore but whenever i run my web app it doesn't run and a new file is opened named web_entrypoint.dart and it hightlights this code This is the highlighted code i have already included firebase script to the html of web app

Here is the screenshot of vscode: vs code screenshot

this is my main function

Future<void> main() async {
  try {
    WidgetsFlutterBinding.ensureInitialized();
    await Firebase.initializeApp();
  } catch (e) {
    print('Failed to initialize');
  }
  runApp(MyApp());
}

Versions - firebase_core: ^1.3.0 cloud_firestore: ^2.3.0 Dart: 2.13.4

Covell answered 6/7, 2021 at 7:50 Comment(7)
Do you get any errors on the console?Vega
No I didn't get any error on the consoleCovell
Okay, looks like your code hit a breakpoint. Please share a screenshot that captures the entire VS Code screenVega
Now I have added the screenshotCovell
Click on the Play icon in blue on the top right corner to get past the breakpoint.Vega
it worked, thx for your time, I added google analytics script in the html file and it start working.Covell
Alright, great. I updated the title and I'll add answer shortly incase any other person faces this issue.Vega
S
1

You are not passing your firebase config to the Firebase.initializeApp function. It should look like this.

import 'package:PROJECTNAME/firebase_options.dart';

void main() async {
    WidgetsFlutterBinding.ensureInitialized();

    await Firebase.initializeApp(
      options: DefaultFirebaseOptions.currentPlatform,
    );

    runApp(child: const MyApp());
 }

You will want to create a firebase_options.dart file that contains the firebase config values required. The most efficient way IMO is to do this with flutterfire which you can find here. https://firebase.google.com/docs/flutter/setup?platform=ios#available-plugins

This page will also walk you through each step. Simply you will.

  1. Install Flutterfire CLI
  2. run flutterfire configure in your terminal / command prompt
  3. Select your required selections from the firebase offerings
  4. Allow it to create the necessary setup files.

They recommend that whenever you add a new option like adding firestore or auth, etc. That you re-run flutterfire configure.

Soelch answered 27/8 at 13:3 Comment(0)
V
0

The screenshot shows that your app paused at the breakpoint, you can just click on the Play button and the app should continue running as expected.

More reading: https://flutter.dev/docs/testing/debugging

Vega answered 6/7, 2021 at 14:17 Comment(1)
Yep, that's right. You have to click play in top right corner of the screenFluorinate

© 2022 - 2024 — McMap. All rights reserved.