skip to Main Content

I’m a newbie trying to build my first Flutter app whilst using MongoDB Atlas as a database, however when I try the following code:

  final db = await Db.create('mongodb+srv://admin:***@cluster0.z286eob.mongodb.net/****?retryWrites=true&w=majority');
  print("AHH");
  await db.open();

The AHH never gets printed, ever. The *** in the URL represents my user password and database name, and they’re correct because
It works when I try it on a real device, but not on the Android emulator with Android Studio.
Can someone help me solve this?

2

Answers


  1. Chosen as BEST ANSWER

    It happened to be some sort of bug with the emulator. When I tried it in a new one, it worked just fine.


  2. You need to have Internet permission in AndroidManifest file.

     <uses-permission android:name="android.permission.INTERNET"/>
    

    The manifest file will be here : projectdirectory/android/app/src/main

    https://i.stack.imgur.com/duO94.png

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search