pinchbv / floor

The typesafe, reactive, and lightweight SQLite abstraction for your Flutter applications
https://pinchbv.github.io/floor/
Apache License 2.0
965 stars 191 forks source link

Need to set null for sqflite database instance when close database. Otherwise it will always return the old instance. #838

Open haidang750 opened 2 months ago

haidang750 commented 2 months ago

In close() function of database.dart file, need to set null for current database before closing it like this: Future close() async { final db = await instance.database; _database = null; await db.close(); }

haidang750 commented 2 months ago

You can find this issue by: https://github.com/tekartik/sqflite/issues/223

haidang750 commented 2 months ago

@stephanmantel please help me

stephanmantel commented 2 months ago

Hi, thanks for your interest in Floor and fr filing this issue, I shall take a look at it

haidang750 commented 2 months ago

thank you very much, my case is switching between different sqflite .db files, so I need to close the current before open the new one, but I got the error Unhandled Exception: DatabaseException(error database_closed) after close