Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Dart Flutter The method 'getDatabasePath' isn't defined for the type 'sqliteDaatabase'. Error

I have a code like this:

import "package:sqflite/sqflite.dart";
import "package:path/path.dart";
import "package:path_provider/path_provider.dart";

class sqliteDaatabase {
  final _dbName = "testsData.db";
  final _tableName = "tests";

  initDb() async {
    String path = await getDatabasePath();
    String createTable = "CREATE TABLE ${_tableName} (name TEXT)";
    openDatabase(join(path, _dbName),
    onCreate: (db, version) {
      db.execute("");
    },
    version: 1,
    );
  }
}

But it throws an error in the code.

Error:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

enter image description here

I think I need to pull a package from the imports section. Can you help me?

>Solution :

Your function name is a typo, try this:
getDatabasesPath()

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading