我正在尝试在iPhone 7上运行我的flutter应用程序,但收到一条错误消息。在我的Android手机以及iPhone XR模拟器上运行该应用程序都可以正常工作。 我还尝试在iPad上测试该应用程序,但收到了完全相同的错误消息,如下所示。用新副本替换ios文件夹并不能解决问题。
我尝试运行最新的sqflite版本,而Flutter Doctor没有显示任何问题。
Future<Database> initDatabase() async {
//Get the dir
Directory directory = await getApplicationDocumentsDirectory();
String path = directory.path + 'posts.db';
//Open or Create the database using given path
var postsDataBase = openDatabase(path, version: 1, onCreate: _createDb);
return postsDataBase;
}
[VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: DatabaseException(open_failed /var/mobile/Containers/Data/Application/04C0A23F-6C36-42C2-9CE5-C7C5370F59FA/Documentsposts.db)
#0 wrapDatabaseException
package:sqflite/src/exception_impl.dart:11
<asynchronous suspension>
#1 SqfliteDatabaseFactoryImpl.wrapDatabaseException
package:sqflite/src/factory_impl.dart:29
#2 SqfliteDatabaseMixin.safeInvokeMethod
package:sqflite/src/database_mixin.dart:184
#3 SqfliteDatabaseMixin.openDatabase
package:sqflite/src/database_mixin.dart:519
<asynchronous suspension>
#4 SqfliteDatabaseMixin.doOpen
package:sqflite/src/database_mixin.dart:612
<asynchronous suspension>
#5 SqfliteDatabaseOpenHelper.openDatabase
package:sqflite/src/database.dart:32
<asynchronous suspension>
#6 SqfliteDatabaseFactoryMixin.openDatabase.<anonymous closure>
package:sqflite/src/factory_mixin.dart:100
<asynchronous suspension>
#7 ReentrantLock.synchronized.<anonymous closure>.<anonymous closure>
package:synchronized/src/reentrant_lock.dart:33
#8 _rootRun (dart:async/zone.dart:1124:13)
答案 0 :(得分:0)
检查父目录是否存在,然后尝试使用最新的sqlite版本。