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
{{ message }}
This repository has been archived by the owner on Mar 6, 2023. It is now read-only.
I am currently trying to insert a different document into objectDb depending on the users locale.
In short, my code currently goes like:
void main() async {
// get document directory using path_provider plugin
Directory appDocDir = await getApplicationDocumentsDirectory();
String dbFilePath = [appDocDir.path, 'user.db'].join('/');
// initialize and open database
db = ObjectDB(dbFilePath);
// delete old database file if exists
File dbFile = File(dbFilePath);
// check if database already exists
var isNew = !await dbFile.exists();
db.open();
if (isNew) {
//insert first document
final document =
r'[{"insert":"Welcome"}];
db.insert({
'document': document,
'key': randomKey,
});
}
}
Now I am wondering: Is it possible to insert a different document into the db depending on the user devices locale? My first try was using Localizations.localeOf(context); which however didn't work because the main() function does not have a context. Is there any other way of achieving this?
PS: Sorry for asking a simple question as an issue, I just didn't find any other place to ask. Thanks a lot for the awesome database! 👍
The text was updated successfully, but these errors were encountered:
I am currently trying to insert a different document into objectDb depending on the users locale.
In short, my code currently goes like:
Now I am wondering: Is it possible to insert a different document into the db depending on the user devices locale? My first try was using
Localizations.localeOf(context);
which however didn't work because themain()
function does not have a context. Is there any other way of achieving this?PS: Sorry for asking a simple question as an issue, I just didn't find any other place to ask. Thanks a lot for the awesome database! 👍
The text was updated successfully, but these errors were encountered: