Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using firebase in dartpad is not working #2426

Closed
hanmo2000110 opened this issue Dec 9, 2022 · 11 comments
Closed

using firebase in dartpad is not working #2426

hanmo2000110 opened this issue Dec 9, 2022 · 11 comments

Comments

@hanmo2000110
Copy link

hanmo2000110 commented Dec 9, 2022

I want to use firebase in dartpad
but in initialize step the error occured

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

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp(
    options: const FirebaseOptions(
      apiKey: "my apikey",
      authDomain: "my project-id.firebaseapp.com",
      projectId: "my project-id",
      storageBucket: "my project-id.appspot.com",
      messagingSenderId: "01012345678",
      appId: "my project-id",
    ),
  );
}

and the error was like that
image

what is the problem?

@domesticmouse
Copy link
Member

DartPad runs the compiler JS inside a sandbox, per the error message. There are security considerations regarding executing user submitted code

@hanmo2000110
Copy link
Author

How we can use firebase in Dartpad
Now we can't use it

@swpark15
Copy link

hi, i'm having the same error in dartpad.dev
Are there no other ways to use Firebase.initializeApp or any other firebase services in dartpad?
How can we test firebase packages in dartpad.dev?

@domesticmouse
Copy link
Member

/cc @puf

@swpark15
Copy link

swpark15 commented Jan 5, 2023

Hi~ I'm curious about how the updates are going on this issue
and I recently found the same error appearing when running the dartpad sample "Firebase Nanochat" as well

I'm currently working on a project that uses dartpad as an educational tool for learning flutter
and with this error I'm kinda stuck in the middle of developing educational contents

I appreciate your efforts and I would really like to see this error get fixed soon

@domesticmouse
Copy link
Member

Hey @puf, any idea why Nanochat used to work, but doesn't now? It's not like we changed the rules on how the sandbox works. I'm guessing FirebaseJS now has additional requirements?

@puf
Copy link

puf commented Jan 5, 2023

When I open the nanochat sample, it works for me:

image

Can you share a non-working dartpad that I can try, or a context that I can otherwise reproduce the problem in?

@swpark15
Copy link

Hi~ thanks for the reply ~!
I've checked the nanochat in dartpad.dev and it's working fine now ~!
and the above issue no longer shows as well when using firebase.initializeApp
wonder what the problems was? I also used regular dartpad.dev and didn't work before
But thanks ~!! and I guess the problem is solved now then?

@domesticmouse
Copy link
Member

We have made no significant changes on the server side since the bug report, so I'm unsure what has changed.

@domesticmouse
Copy link
Member

Closing, as this isn't currently an issue. Please comment if the issue reappears.

@hongsw
Copy link

hongsw commented Sep 5, 2023

https://dartpad.dev/?id=d57c6c898dabb8c6fb41018588b8cf73 and I get an error.
It worked fine in March 2023, but when I went in today and tried to show a demo, I got an error. Thanks.

Error compiling to JavaScript:
local_pub_cache/hosted/pub.dev/cloud_firestore-4.8.5/lib/src/firestore.dart:50:46: Error: Required named parameter 'databaseURL' must be provided.
        FirebaseFirestorePlatform.instanceFor(app: app);
                                             ^
local_pub_cache/hosted/pub.dev/cloud_firestore_platform_interface-5.16.0/lib/src/platform_interface/platform_interface_firestore.dart:40:11: Context: Found this candidate, but the arguments don't match.
  factory FirebaseFirestorePlatform.instanceFor({
          ^^^^^^^^^^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants