Dart Flutter 方法“getDatabasePath”没有为“sqliteDatabase”类型定义。错误
我有这样的代码:
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,
);
}
}
但它会在代码中引发错误。
错误:
我想我需要从导入部分提取一个包。你能帮助我吗?
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:
I think I need to pull a package from the imports section. Can you help me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的函数名称有一个拼写错误,请尝试以下操作:
getDatabasesPath()
Your function name is a typo, try this:
getDatabasesPath()