You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My requirement is to restore data, so I need to close the database first, then overwrite the database file and reopen it. However, when I use dao.queryStream with StreamBuilder, closing the database will prompt that the database has already been closed. How can I write this logic correctly?
I think you should not directly rely on the Stream in the StreamBuilder. If you use a StreamBuilder directly, I think it will expect to be responsible for the closing, so when you close it yourself, it might continue tryin to read a closed stream.
I think you will have to manage this yourself, depending on your app's architecture, a StatefulWidget might do.
How can I solve the issue where a StreamBuilder refreshes and throws an exception when I try to close the database?
E/flutter ( 4865): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: DatabaseException(error database_closed)
E/flutter ( 4865): #0 SqfliteDatabaseMixin.checkNotClosed
package:sqflite_common/src/database_mixin.dart:337
E/flutter ( 4865): #1 SqfliteDatabaseExecutorMixin._rawQuery
package:sqflite_common/src/database_mixin.dart:124
E/flutter ( 4865): #2 SqfliteDatabaseExecutorMixin.query
package:sqflite_common/src/database_mixin.dart:10
The text was updated successfully, but these errors were encountered: