tekartik / sembast.dart

Simple io database
BSD 2-Clause "Simplified" License
780 stars 64 forks source link

Unhandled Exception: Bad state: read only #293

Open JoelSuyati opened 2 years ago

JoelSuyati commented 2 years ago

while storing data to sembast

alextekartik commented 2 years ago

More information would help, which platform, database location, some code example...can you write a file at the database location?.

owenkealey commented 2 years ago

@alextekartik I get the following error when creating a new database:

"Cannot create file OS Error Read only file system" on an iOS 15 simulator on latest MacOS

alextekartik commented 2 years ago

@owenkealey Same response: More information would help, database location, some code example...can you write a file at the database location?.

m-zaink commented 2 years ago

Here is how to fix this-

ref = StoreRef<String, String>.main();

final applicationDirectory = await getApplicationDocumentsDirectory();

final databasePath = applicationDirectory.path + '/twitter.da';

final db = await databaseFactoryIo.openDatabase(databasePath);

You would need to install path_provider plugin to use getApplicationDocuementsDirectory() function.

SeaRoth commented 2 years ago

Hero.