Flutter Web with Firebase, error "No module for dart_sdk.js"

Viewed 286

When running Firebase on android, there is no problem, but when debugging on the web (chrome or edge), it doesn't work... in the Debug Console a DART_SDK.JS problem notification appears, like this:

"Locations: No module for http://localhost:53xxx/dart_sdk.js"

This notification only appears when running at Firebase.initializeApp();

My Code:

void main() async {
      WidgetsFlutterBinding.ensureInitialized();
      await Firebase.initializeApp();
    
      runApp(
        MaterialApp(
          title: "Firebase", 
          home: MyApp()
        )
      );
    }
1 Answers

The problem is that you need to configure some extra things for web to work in your initializeApp method

 Platform.isAndroid? await Firebase.initializeApp():await Firebase.initializeApp(
        // Replace with actual values
        options: const FirebaseOptions(
          apiKey: "your api key from firebase console here ",
          appId: "your apid from firebase console here",
          messagingSenderId: "XXX",
          projectId: "your project id",
        ),
      );
Related