Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created September 20, 2022 19:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/4a58753196798321a255ad2fb2e003ee to your computer and use it in GitHub Desktop.
Save parzibyte/4a58753196798321a255ad2fb2e003ee to your computer and use it in GitHub Desktop.
Database db;
if (Platform.isWindows || Platform.isLinux) {
// Initialize FFI
sqfliteFfiInit();
var databaseFactory = databaseFactoryFfi;
db = await databaseFactory.openDatabase(join(".", "ejemplo.db"));
} else {
db = await openDatabase(
// Set the path to the database. Note: Using the `join` function from the
// `path` package is best practice to ensure the path is correctly
// constructed for each platform.
join(await getDatabasesPath(), 'ejemplo.db'),
// When the database is first created, create a table to store dogs.
onCreate: (db, version) {
// Run the CREATE TABLE statement on the database.
},
// Set the version. This executes the onCreate function and provides a
// path to perform database upgrades and downgrades.
version: 1,
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment