
I am trying to connect my mongodb to flutter and this is how my database.dart
file looks
import 'package:mongo_dart/mongo_dart.dart';
import 'package:restro_app/database/constant.dart';
import 'package:restro_app/models/menu_model.dart';
class MongoDatabase {
static var db, userCollection;
//Connection to the database
static connect() async {
db = await Db.create(MONGO_CONN_URL);
await db.open();
userCollection = db.collection(DATA_COLLECTION);
}
// More code..

But when I started to debug I realised that the variable db isn't getting any values

it returns Db(null, null)

const MONGO_CONN_URL = "mongodb+srv://127.0.0.1:27017/Restaurant";

This is how my connection string looks

Not sure what is going wrong

Hi 馃憢

127.0.0.1 - is localhost?

You need to use public IP or a domain to connect to their MongoDB server.

FYI, since this is an Appwrite (https://appwrite.io/) discord server, for general flutter questions, you might find more help in a Flutter discord server (https://flutter.dev/community#community-grid).

[SOLVED] How to connect MongoDB with flutter

Closing this thread for now, if you have appwrite specific questions, please open a new thread 馃檪
Recommended threads
- Hola equipo de soporte,
Hola equipo de soporte, Estoy desarrollando una Function en Appwrite Cloud con Node.js 22 y el siguiente package.json: {聽聽"name":聽"upload-whitelist",聽聽"type"...
- Sites 30MB limit from GitHub
I鈥檓 deploying a site from github as Other type on the Hobby plan. It is actually a Flutter web app but it鈥檚 in a subdirectory with the root being an html landin...
- Query params are way too limiting in ter...
I was trying to list rows in a table that do not already exist in another table. I retrieved around 260 row IDs which are 13 characters in length each, and then...
