CINXE.COM
sqflite | Flutter package
<!DOCTYPE html> <html lang="en-us"><head><script src="https://www.googletagmanager.com/gtm.js?id=GTM-MX6DBN9" async="async"></script><script src="/static/hash-o6oemknr/js/gtm.js" async="async"></script><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="ie=edge"/><meta name="viewport" content="width=device-width, initial-scale=1"/><meta name="twitter:card" content="summary"/><meta name="twitter:site" content="@dart_lang"/><meta name="twitter:description" content="Flutter plugin for SQLite, a self-contained, high-reliability, embedded, SQL database engine."/><meta name="twitter:image" content="https://pub.dev/static/hash-o6oemknr/img/pub-dev-icon-cover-image.png"/><meta property="og:type" content="website"/><meta property="og:site_name" content="Dart packages"/><meta property="og:title" content="sqflite | Flutter package"/><meta property="og:description" content="Flutter plugin for SQLite, a self-contained, high-reliability, embedded, SQL database engine."/><meta property="og:image" content="https://pub.dev/static/hash-o6oemknr/img/pub-dev-icon-cover-image.png"/><meta property="og:url" content="https://pub.dev/packages/sqflite"/><title>sqflite | Flutter package</title><link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Google+Sans:wght@400;500;700&family=Google+Sans+Display:wght@400&family=Google+Sans+Text:wght@400;500;700&family=Google+Sans+Mono:wght@400;700&display=swap"/><link rel="shortcut icon" href="/static/hash-o6oemknr/img/flutter-logo-32x32.png"/><link rel="stylesheet" href="https://www.gstatic.com/glue/v25_0/ccb.min.css"/><link rel="search" type="application/opensearchdescription+xml" title="Dart packages" href="/osd.xml"/><link rel="canonical" href="https://pub.dev/packages/sqflite"/><meta name="description" content="Flutter plugin for SQLite, a self-contained, high-reliability, embedded, SQL database engine."/><link rel="alternate" type="application/atom+xml" title="Updated Packages Feed for Pub" href="/feed.atom"/><link rel="stylesheet" type="text/css" href="/static/hash-o6oemknr/material/bundle/styles.css"/><link rel="stylesheet" type="text/css" href="/static/hash-o6oemknr/css/style.css"/><script src="/static/hash-o6oemknr/material/bundle/script.min.js" defer="defer"></script><script src="/static/hash-o6oemknr/js/script.dart.js" defer="defer"></script><script src="https://www.gstatic.com/brandstudio/kato/cookie_choice_component/cookie_consent_bar.v3.js" defer="defer" data-autoload-cookie-consent-bar="true"></script><meta name="pub-page-data" content="eyJwa2dEYXRhIjp7InBhY2thZ2UiOiJzcWZsaXRlIiwidmVyc2lvbiI6IjIuNC4xIiwibGlrZXMiOjUwODUsInB1Ymxpc2hlcklkIjoidGVrYXJ0aWsuY29tIiwiaXNEaXNjb250aW51ZWQiOmZhbHNlLCJpc0xhdGVzdCI6dHJ1ZX0sInNlc3Npb25Bd2FyZSI6ZmFsc2V9"/><link rel="preload" href="/static/hash-o6oemknr/highlight/highlight-with-init.js" as="script"/></head><body class="light-theme"><script src="/static/hash-o6oemknr/js/dark-init.js"></script><noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript><div class="site-header"><button class="hamburger" aria-label="menu toggle"></button><a class="logo" href="/"><img class="site-logo" src="/static/hash-o6oemknr/img/pub-dev-logo.svg" alt="" width="140" height="30" role="presentation"/></a><div class="site-header-space"></div><div class="site-header-mask"></div><div class="site-header-search"><form action="/packages" method="GET"><input class="site-header-search-input" name="q" placeholder="New search..." autocomplete="on" title="Search"/></form></div><nav class="site-header-nav scroll-container"><div class="nav-login-container"><button id="-account-login" class="nav-main-button link">Sign in</button></div><div class="nav-container nav-help-container hoverable"><button class="nav-main-button">Help</button><div class="nav-hover-popup"><div class="nav-table-columns"><div class="nav-table-column"><h3>Pub.dev</h3><a class="nav-link" href="/help/search" rel="noopener" target="_blank">Searching for packages</a><a class="nav-link" href="/help/scoring" rel="noopener" target="_blank">Package scoring and pub points</a></div><div class="nav-table-column"><h3>Flutter</h3><a class="nav-link" href="https://flutter.dev/using-packages/" rel="noopener" target="_blank">Using packages</a><a class="nav-link" href="https://flutter.dev/developing-packages/" rel="noopener" target="_blank">Developing packages and plugins</a><a class="nav-link" href="https://dart.dev/tools/pub/publishing" rel="noopener" target="_blank">Publishing a package</a></div><div class="nav-table-column"><h3>Dart</h3><a class="nav-link" href="https://dart.dev/guides/packages" rel="noopener" target="_blank">Using packages</a><a class="nav-link" href="https://dart.dev/tools/pub/publishing" rel="noopener" target="_blank">Publishing a package</a></div></div></div></div><div class="nav-container nav-help-container-mobile foldable"><h3 class="foldable-button">Pub.dev <img class="foldable-icon" src="/static/hash-o6oemknr/img/nav-mobile-foldable-icon.svg" alt="toggle folding of the section" width="13" height="6"/></h3><div class="foldable-content"><a class="nav-link" href="/help/search" rel="noopener" target="_blank">Searching for packages</a><a class="nav-link" href="/help/scoring" rel="noopener" target="_blank">Package scoring and pub points</a></div></div><div class="nav-container nav-help-container-mobile foldable"><h3 class="foldable-button">Flutter <img class="foldable-icon" src="/static/hash-o6oemknr/img/nav-mobile-foldable-icon.svg" alt="toggle folding of the section" width="13" height="6"/></h3><div class="foldable-content"><a class="nav-link" href="https://flutter.dev/using-packages/" rel="noopener" target="_blank">Using packages</a><a class="nav-link" href="https://flutter.dev/developing-packages/" rel="noopener" target="_blank">Developing packages and plugins</a><a class="nav-link" href="https://dart.dev/tools/pub/publishing" rel="noopener" target="_blank">Publishing a package</a></div></div><div class="nav-container nav-help-container-mobile foldable"><h3 class="foldable-button">Dart <img class="foldable-icon" src="/static/hash-o6oemknr/img/nav-mobile-foldable-icon.svg" alt="toggle folding of the section" width="13" height="6"/></h3><div class="foldable-content"><a class="nav-link" href="https://dart.dev/guides/packages" rel="noopener" target="_blank">Using packages</a><a class="nav-link" href="https://dart.dev/tools/pub/publishing" rel="noopener" target="_blank">Publishing a package</a></div></div></nav></div><div id="banner-container"></div><main class="container"><div class="detail-wrapper -active -has-info-box"><div class="detail-banners"><a href="https://flutter.dev/docs/development/packages-and-plugins/favorites" rel="noopener" target="_blank"><img class="ff-banner ff-banner-desktop displayed-in-light-theme" src="/static/hash-o6oemknr/img/ff-banner-desktop-2x.png" alt="" width="150" height="218" title="Package is a Flutter Favorite" role="presentation"/><img class="ff-banner ff-banner-desktop displayed-in-dark-theme" src="/static/hash-o6oemknr/img/ff-banner-desktop-dark-2x.png" alt="" width="150" height="218" title="Package is a Flutter Favorite" role="presentation"/><img class="ff-banner ff-banner-mobile displayed-in-light-theme" src="/static/hash-o6oemknr/img/ff-banner-mobile-2x.png" alt="" width="94" height="116" title="Package is a Flutter Favorite" role="presentation"/><img class="ff-banner ff-banner-mobile displayed-in-dark-theme" src="/static/hash-o6oemknr/img/ff-banner-mobile-dark-2x.png" alt="" width="94" height="116" title="Package is a Flutter Favorite" role="presentation"/></a></div><div class="detail-header -is-loose"><div class="detail-container"><div class="detail-header-outer-block"><div class="detail-header-content-block"><h1 class="title">sqflite 2.4.1 <span class="pkg-page-title-copy"><img class="pkg-page-title-copy-icon filter-invert-on-dark" src="/static/hash-o6oemknr/img/content-copy-icon.svg" alt="copy "sqflite: ^2.4.1" to clipboard" width="18" height="18" title="Copy "sqflite: ^2.4.1" to clipboard" data-copy-content="sqflite: ^2.4.1" data-ga-click-event="copy-package-version"/><div class="pkg-page-title-copy-feedback"><span class="code">sqflite: ^2.4.1</span> copied to clipboard</div></span></h1><div class="metadata">Published <span><a class="-x-ago" href="" title="Nov 8, 2024" aria-label="16 days ago" aria-role="button" role="button" data-timestamp="1731028483962">16 days ago</a></span> • <a class="-pub-publisher" href="/publishers/tekartik.com"><img class="-pub-publisher-shield filter-invert-on-dark" src="/static/hash-o6oemknr/img/material-icon-verified.svg" alt="verified publisher" width="14" height="14" title="Published by a pub.dev verified publisher"/>tekartik.com</a><span class="package-badge" title="Package is compatible with Dart 3.">Dart 3 compatible</span></div><div class="detail-tags-and-like"><div class="detail-tags"><div class="-pub-tag-badge"><span class="tag-badge-main">SDK</span><a class="tag-badge-sub" href="/packages?q=sdk%3Aflutter" rel="nofollow" title="Packages compatible with Flutter SDK">Flutter</a></div><div class="-pub-tag-badge"><span class="tag-badge-main">Platform</span><a class="tag-badge-sub" href="/packages?q=platform%3Aandroid" rel="nofollow" title="Packages compatible with Android platform">Android</a><a class="tag-badge-sub" href="/packages?q=platform%3Aios" rel="nofollow" title="Packages compatible with iOS platform">iOS</a><a class="tag-badge-sub" href="/packages?q=platform%3Amacos" rel="nofollow" title="Packages compatible with macOS platform">macOS</a></div></div><div class="detail-like"><button id="-pub-like-icon-button" class="mdc-icon-button" data-ga-click-event="toggle-like" aria-pressed="false" title="Like this package"><img class="mdc-icon-button__icon" src="/static/hash-o6oemknr/img/like-inactive.svg" alt="liked status: inactive" width="18" height="18"/><img class="mdc-icon-button__icon mdc-icon-button__icon--on" src="/static/hash-o6oemknr/img/like-active.svg" alt="liked status: active" width="18" height="18"/></button><span class="likes-count"><span id="likes-count">5.0k</span></span></div></div></div></div></div></div><div class="detail-container"><div class="detail-lead"><div class="detail-metadata-toggle"><div class="detail-metadata-toggle-icon">→</div><h3 class="detail-lead-title">Metadata</h3></div><p class="detail-lead-text">Flutter plugin for SQLite, a self-contained, high-reliability, embedded, SQL database engine.</p><p class="detail-lead-more"><a class="detail-metadata-toggle">More...</a></p></div></div><div class="detail-body"><div class="detail-tabs"><div class="detail-tabs-wide-header"><div class="detail-container"><ul class="detail-tabs-header"><li class="detail-tab tab-button detail-tab-readme-title -active">Readme</li><li class="detail-tab tab-link detail-tab-changelog-title"><a href="/packages/sqflite/changelog" role="button">Changelog</a></li><li class="detail-tab tab-link detail-tab-example-title"><a href="/packages/sqflite/example" role="button">Example</a></li><li class="detail-tab tab-link detail-tab-installing-title"><a href="/packages/sqflite/install" role="button">Installing</a></li><li class="detail-tab tab-link detail-tab-versions-title"><a href="/packages/sqflite/versions" role="button">Versions</a></li><li class="detail-tab tab-link detail-tab-analysis-title"><a href="/packages/sqflite/score" role="button">Scores</a></li></ul></div></div><div class="detail-container detail-body-main"><div class="detail-tabs-content"><section class="tab-content detail-tab-readme-content -active markdown-body"><h1 class="hash-header" id="sqflite">sqflite <a href="#sqflite" class="hash-link">#</a></h1> <p><a href="https://pub.dev/packages/sqflite"><img src="https://img.shields.io/pub/v/sqflite.svg" alt="pub package"></a></p> <p>SQLite plugin for <a href="https://flutter.io" rel="ugc">Flutter</a>. Supports iOS, Android and MacOS.</p> <ul> <li>Support transactions and batches</li> <li>Automatic version managment during open</li> <li>Helpers for insert/query/update/delete queries</li> <li>DB operation executed in a background thread on iOS and Android</li> </ul> <p>Other platforms support:</p> <ul> <li>Linux/Windows/DartVM support using <a href="https://pub.dev/packages/sqflite_common_ffi">sqflite_common_ffi</a></li> <li>Experimental Web support using <a href="https://pub.dev/packages/sqflite_common_ffi_web">sqflite_common_ffi_web</a>.</li> </ul> <p>Usage example:</p> <ul> <li><a href="https://github.com/alextekartik/flutter_app_example/tree/master/notepad_sqflite" rel="ugc">notepad_sqflite</a>: Simple flutter notepad working on iOS/Android/Windows/linux/Mac</li> </ul> <h2 class="hash-header" id="getting-started">Getting Started <a href="#getting-started" class="hash-link">#</a></h2> <p>To get started, you need to add <code>sqflite</code> to your project. Follow the steps below:</p> <ol> <li> <p>Open the terminal in your project root. You can do this by pressing <code>Alt+F12</code> in Android Studio or <code>Ctrl+`</code> in VS Code.</p> </li> <li> <p>Run the following command:</p> </li> </ol> <pre><code class="language-bash">flutter pub add sqflite </code></pre> <p>This command will add a line to your package's <code>pubspec.yaml</code> file and run an implicit <code>flutter pub get</code>. The added line will look like this:</p> <pre><code class="language-yaml">dependencies: sqflite: </code></pre> <h2 class="hash-header" id="usage-example">Usage example <a href="#usage-example" class="hash-link">#</a></h2> <p>Import <code>sqflite.dart</code></p> <pre><code class="language-dart">import 'package:sqflite/sqflite.dart'; </code></pre> <h3 class="hash-header" id="opening-a-database">Opening a database <a href="#opening-a-database" class="hash-link">#</a></h3> <p>A SQLite database is a file in the file system identified by a path. If relative, this path is relative to the path obtained by <code>getDatabasesPath()</code>, which is the default database directory on Android and the documents directory on iOS/MacOS.</p> <pre><code class="language-dart">var db = await openDatabase('my_db.db'); </code></pre> <p>There is a basic migration mechanism to handle schema changes during opening.</p> <p>Many applications use one database and would never need to close it (it will be closed when the application is terminated). If you want to release resources, you can close the database.</p> <pre><code class="language-dart">await db.close(); </code></pre> <ul> <li>See <a href="https://github.com/tekartik/sqflite/blob/master/sqflite/doc/opening_db.md" rel="ugc">more information on opening a database</a>.</li> <li>Full <a href="https://github.com/tekartik/sqflite/blob/master/sqflite/doc/migration_example.md" rel="ugc">migration example</a></li> </ul> <h3 class="hash-header" id="raw-sql-queries">Raw SQL queries <a href="#raw-sql-queries" class="hash-link">#</a></h3> <p>Demo code to perform Raw SQL queries</p> <pre><code class="language-dart">// Get a location using getDatabasesPath var databasesPath = await getDatabasesPath(); String path = join(databasesPath, 'demo.db'); // Delete the database await deleteDatabase(path); // open the database Database database = await openDatabase(path, version: 1, onCreate: (Database db, int version) async { // When creating the db, create the table await db.execute( 'CREATE TABLE Test (id INTEGER PRIMARY KEY, name TEXT, value INTEGER, num REAL)'); }); // Insert some records in a transaction await database.transaction((txn) async { int id1 = await txn.rawInsert( 'INSERT INTO Test(name, value, num) VALUES("some name", 1234, 456.789)'); print('inserted1: $id1'); int id2 = await txn.rawInsert( 'INSERT INTO Test(name, value, num) VALUES(?, ?, ?)', ['another name', 12345678, 3.1416]); print('inserted2: $id2'); }); // Update some record int count = await database.rawUpdate( 'UPDATE Test SET name = ?, value = ? WHERE name = ?', ['updated name', '9876', 'some name']); print('updated: $count'); // Get the records List<Map> list = await database.rawQuery('SELECT * FROM Test'); List<Map> expectedList = [ {'name': 'updated name', 'id': 1, 'value': 9876, 'num': 456.789}, {'name': 'another name', 'id': 2, 'value': 12345678, 'num': 3.1416} ]; print(list); print(expectedList); assert(const DeepCollectionEquality().equals(list, expectedList)); // Count the records count = Sqflite .firstIntValue(await database.rawQuery('SELECT COUNT(*) FROM Test')); assert(count == 2); // Delete a record count = await database .rawDelete('DELETE FROM Test WHERE name = ?', ['another name']); assert(count == 1); // Close the database await database.close(); </code></pre> <p>Basic information on SQL <a href="https://github.com/tekartik/sqflite/blob/master/sqflite/doc/sql.md" rel="ugc">here</a>.</p> <h3 class="hash-header" id="sql-helpers">SQL helpers <a href="#sql-helpers" class="hash-link">#</a></h3> <p>Example using the helpers</p> <pre><code class="language-dart">final String tableTodo = 'todo'; final String columnId = '_id'; final String columnTitle = 'title'; final String columnDone = 'done'; class Todo { int id; String title; bool done; Map<String, Object?> toMap() { var map = <String, Object?>{ columnTitle: title, columnDone: done == true ? 1 : 0 }; if (id != null) { map[columnId] = id; } return map; } Todo(); Todo.fromMap(Map<String, Object?> map) { id = map[columnId]; title = map[columnTitle]; done = map[columnDone] == 1; } } class TodoProvider { Database db; Future open(String path) async { db = await openDatabase(path, version: 1, onCreate: (Database db, int version) async { await db.execute(''' create table $tableTodo ( $columnId integer primary key autoincrement, $columnTitle text not null, $columnDone integer not null) '''); }); } Future<Todo> insert(Todo todo) async { todo.id = await db.insert(tableTodo, todo.toMap()); return todo; } Future<Todo> getTodo(int id) async { List<Map> maps = await db.query(tableTodo, columns: [columnId, columnDone, columnTitle], where: '$columnId = ?', whereArgs: [id]); if (maps.length > 0) { return Todo.fromMap(maps.first); } return null; } Future<int> delete(int id) async { return await db.delete(tableTodo, where: '$columnId = ?', whereArgs: [id]); } Future<int> update(Todo todo) async { return await db.update(tableTodo, todo.toMap(), where: '$columnId = ?', whereArgs: [todo.id]); } Future close() async => db.close(); } </code></pre> <h3 class="hash-header" id="read-results">Read results <a href="#read-results" class="hash-link">#</a></h3> <p>Assuming the following read results:</p> <pre><code class="language-dart">List<Map<String, Object?>> records = await db.query('my_table'); </code></pre> <p>Resulting map items are read-only</p> <pre><code class="language-dart">// get the first record Map<String, Object?> mapRead = records.first; // Update it in memory...this will throw an exception mapRead['my_column'] = 1; // Crash... `mapRead` is read-only </code></pre> <p>You need to create a new map if you want to modify it in memory:</p> <pre><code class="language-dart">// get the first record Map<String, Object?> map = Map<String, Object?>.from(mapRead); // Update it in memory now map['my_column'] = 1; </code></pre> <h3 class="hash-header" id="transaction">Transaction <a href="#transaction" class="hash-link">#</a></h3> <p>Don't use the database but only use the Transaction object in a transaction to access the database. Keep in mind that the callbacks <code>onCreate</code> <code>onUpgrade</code> <code>onDowngrade</code> are already internally wrapped in a transaction, so there is no need to wrap your statements in a transaction within those callbacks.</p> <pre><code class="language-dart">await database.transaction((txn) async { // Ok await txn.execute('CREATE TABLE Test1 (id INTEGER PRIMARY KEY)'); // DON'T use the database object in a transaction // this will deadlock! await database.execute('CREATE TABLE Test2 (id INTEGER PRIMARY KEY)'); }); </code></pre> <p>A transaction is committed if the callback does not throw an error. If an error is thrown, the transaction is cancelled. So to rollback a transaction one way is to throw an exception.</p> <h3 class="hash-header" id="batch-support">Batch support <a href="#batch-support" class="hash-link">#</a></h3> <p>To avoid ping-pong between dart and native code, you can use <code>Batch</code>:</p> <pre><code class="language-dart">batch = db.batch(); batch.insert('Test', {'name': 'item'}); batch.update('Test', {'name': 'new_item'}, where: 'name = ?', whereArgs: ['item']); batch.delete('Test', where: 'name = ?', whereArgs: ['item']); results = await batch.commit(); </code></pre> <p>Getting the result for each operation has a cost (id for insertion and number of changes for update and delete), especially on Android where an extra SQL request is executed. If you don't care about the result and worry about performance in big batches, you can use</p> <pre><code class="language-dart">await batch.commit(noResult: true); </code></pre> <p>Warning, during a transaction, the batch won't be committed until the transaction is committed</p> <pre><code class="language-dart">await database.transaction((txn) async { var batch = txn.batch(); // ... // commit but the actual commit will happen when the transaction is committed // however the data is available in this transaction await batch.commit(); // ... }); </code></pre> <p>By default a batch stops as soon as it encounters an error (which typically reverts the uncommitted changes). You can ignore errors so that every successfull operation is ran and committed even if one operation fails:</p> <pre><code class="language-dart">await batch.commit(continueOnError: true); </code></pre> <h2 class="hash-header" id="table-and-column-names">Table and column names <a href="#table-and-column-names" class="hash-link">#</a></h2> <p>In general it is better to avoid using SQLite keywords for entity names. If any of the following name is used:</p> <pre><code>"add","all","alter","and","as","autoincrement","between","case","check","collate","commit","constraint","create","default","deferrable","delete","distinct","drop","else","escape","except","exists","foreign","from","group","having","if","in","index","insert","intersect","into","is","isnull","join","limit","not","notnull","null","on","or","order","primary","references","select","set","table","then","to","transaction","union","unique","update","using","values","when","where" </code></pre> <p>the helper will <em>escape</em> the name i.e.</p> <pre><code class="language-dart">db.query('table') </code></pre> <p>will be equivalent to manually adding double-quote around the table name (confusingly here named <code>table</code>)</p> <pre><code class="language-dart">db.rawQuery('SELECT * FROM "table"'); </code></pre> <p>However in any other raw statement (including <code>orderBy</code>, <code>where</code>, <code>groupBy</code>), make sure to escape the name properly using double quote. For example see below where the column name <code>group</code> is not escaped in the columns argument, but is escaped in the <code>where</code> argument.</p> <pre><code class="language-dart">db.query('table', columns: ['group'], where: '"group" = ?', whereArgs: ['my_group']); </code></pre> <h2 class="hash-header" id="supported-sqlite-types">Supported SQLite types <a href="#supported-sqlite-types" class="hash-link">#</a></h2> <p>No validity check is done on values yet so please avoid non supported types <a href="https://www.sqlite.org/datatype3.html" rel="ugc">https://www.sqlite.org/datatype3.html</a></p> <p><code>DateTime</code> is not a supported SQLite type. Personally I store them as int (millisSinceEpoch) or string (iso8601)</p> <p><code>bool</code> is not a supported SQLite type. Use <code>INTEGER</code> and 0 and 1 values.</p> <p>More information on supported types <a href="https://github.com/tekartik/sqflite/blob/master/sqflite/doc/supported_types.md" rel="ugc">here</a>.</p> <h3 class="hash-header" id="integer">INTEGER <a href="#integer" class="hash-link">#</a></h3> <ul> <li>Dart type: <code>int</code></li> <li>Supported values: from -2^63 to 2^63 - 1</li> </ul> <h3 class="hash-header" id="real">REAL <a href="#real" class="hash-link">#</a></h3> <ul> <li>Dart type: <code>num</code></li> </ul> <h3 class="hash-header" id="text">TEXT <a href="#text" class="hash-link">#</a></h3> <ul> <li>Dart type: <code>String</code></li> </ul> <h3 class="hash-header" id="blob">BLOB <a href="#blob" class="hash-link">#</a></h3> <ul> <li>Dart type: <code>Uint8List</code></li> </ul> <h2 class="hash-header" id="current-issues">Current issues <a href="#current-issues" class="hash-link">#</a></h2> <ul> <li>Due to the way transaction works in SQLite (threads), concurrent read and write transaction are not supported. All calls are currently synchronized and transactions block are exclusive. I thought that a basic way to support concurrent access is to open a database multiple times but it only works on iOS as Android reuses the same database object. I also thought a native thread could be a potential future solution however on android accessing the database in another thread is blocked while in a transaction...</li> </ul> <h2 class="hash-header" id="more">More <a href="#more" class="hash-link">#</a></h2> <ul> <li><a href="https://github.com/tekartik/sqflite/blob/master/sqflite/doc/how_to.md" rel="ugc">How to</a> guide</li> <li><a href="https://github.com/tekartik/sqflite/blob/master/sqflite/doc/desktop_support.md" rel="ugc">Notes about Desktop support</a></li> <li><a href="https://github.com/tekartik/sqflite/blob/master/sqflite/doc/encryption_support.md" rel="ugc">Notes about Encryption support</a></li> <li><a href="https://github.com/tekartik/sqflite/blob/master/sqflite/doc/web_support.md" rel="ugc">Notes about Web support</a></li> <li><a href="https://github.com/tekartik/sqflite/blob/master/sqflite/doc/version.md" rel="ugc">Notes about SQLite versions</a> as some features may not be available depending on the SQLite version.</li> </ul> </section></div></div></div><aside class="detail-info-box"><a class="packages-scores" href="/packages/sqflite/score"><div class="packages-score packages-score-like"><div class="packages-score-value -has-value"><span class="packages-score-value-number">5085</span><span class="packages-score-value-sign"></span></div><div class="packages-score-label">likes</div></div><div class="packages-score packages-score-health"><div class="packages-score-value -has-value"><span class="packages-score-value-number">160</span><span class="packages-score-value-sign"></span></div><div class="packages-score-label">pub points</div></div><div class="packages-score packages-score-popularity"><div class="packages-score-value -has-value"><span class="packages-score-value-number">100</span><span class="packages-score-value-sign">%</span></div><div class="packages-score-label">popularity</div></div></a><h3 class="title">Publisher</h3><p><a href="/publishers/tekartik.com"><img class="-pub-publisher-shield filter-invert-on-dark" src="/static/hash-o6oemknr/img/material-icon-verified.svg" alt="verified publisher" width="14" height="14" title="Published by a pub.dev verified publisher"/>tekartik.com</a></p><h3 class="title pkg-infobox-metadata">Metadata</h3><p>Flutter plugin for SQLite, a self-contained, high-reliability, embedded, SQL database engine.</p><p><a class="link" href="https://github.com/tekartik/sqflite/tree/master/sqflite" rel="ugc">Repository (GitHub)</a><br/><a class="link" href="https://github.com/tekartik/sqflite/issues" rel="ugc">View/report issues</a><br/></p><h3 class="title">Topics</h3><p><a href="/packages?q=topic%3Asql" rel="nofollow">#sql</a> <a href="/packages?q=topic%3Adatabase" rel="nofollow">#database</a></p><h3 class="title">Documentation</h3><p><a class="link" href="/documentation/sqflite/latest/">API reference</a><br/></p><h3 class="title">Funding</h3><p>Consider supporting this project:<br/><br/><a class="link" href="https://github.com/sponsors/alextekartik" rel="ugc">github.com</a><br/></p><h3 class="title">License</h3><p><img class="inline-icon-img filter-invert-on-dark" src="/static/hash-o6oemknr/img/material-icon-balance.svg" alt="" width="14" height="14" role="presentation"/>BSD-2-Clause (<a href="/packages/sqflite/license">license</a>)</p><h3 class="title">Dependencies</h3><p><a href="https://api.flutter.dev/">flutter</a>, <a href="/packages/path" title=">=1.8.0 <3.0.0">path</a>, <a href="/packages/sqflite_android" title=">=2.4.0-1 <4.0.0">sqflite_android</a>, <a href="/packages/sqflite_common" title=">=2.5.0-1 <4.0.0">sqflite_common</a>, <a href="/packages/sqflite_darwin" title=">=2.4.1 <4.0.0">sqflite_darwin</a>, <a href="/packages/sqflite_platform_interface" title=">=2.4.0-0 <4.0.0">sqflite_platform_interface</a></p><h3 class="title">More</h3><p><a href="/packages?q=dependency%3Asqflite" rel="nofollow">Packages that depend on sqflite</a></p></aside></div><script type="application/ld+json">{"@context":"http\u003a\u002f\u002fschema.org","@type":"SoftwareSourceCode","name":"sqflite","version":"2.4.1","description":"sqflite - Flutter plugin for SQLite, a self-contained, high-reliability, embedded, SQL database engine.","url":"https\u003a\u002f\u002fpub.dev\u002fpackages\u002fsqflite","dateCreated":"2017-06-28T12\u003a48\u003a08.957667Z","dateModified":"2024-11-08T01\u003a14\u003a43.962540Z","programmingLanguage":"Dart","image":"https\u003a\u002f\u002fpub.dev\u002fstatic\u002fimg\u002fpub-dev-icon-cover-image.png","license":"https\u003a\u002f\u002fpub.dev\u002fpackages\u002fsqflite\u002flicense"}</script></div><div class="detail-metadata"><h3 class="detail-metadata-title"><span class="detail-metadata-toggle">←</span> Metadata</h3><div class="detail-info-box"><a class="packages-scores" href="/packages/sqflite/score"><div class="packages-score packages-score-like"><div class="packages-score-value -has-value"><span class="packages-score-value-number">5085</span><span class="packages-score-value-sign"></span></div><div class="packages-score-label">likes</div></div><div class="packages-score packages-score-health"><div class="packages-score-value -has-value"><span class="packages-score-value-number">160</span><span class="packages-score-value-sign"></span></div><div class="packages-score-label">pub points</div></div><div class="packages-score packages-score-popularity"><div class="packages-score-value -has-value"><span class="packages-score-value-number">100</span><span class="packages-score-value-sign">%</span></div><div class="packages-score-label">popularity</div></div></a><h3 class="title">Publisher</h3><p><a href="/publishers/tekartik.com"><img class="-pub-publisher-shield filter-invert-on-dark" src="/static/hash-o6oemknr/img/material-icon-verified.svg" alt="verified publisher" width="14" height="14" title="Published by a pub.dev verified publisher"/>tekartik.com</a></p><h3 class="title pkg-infobox-metadata">Metadata</h3><p>Flutter plugin for SQLite, a self-contained, high-reliability, embedded, SQL database engine.</p><p><a class="link" href="https://github.com/tekartik/sqflite/tree/master/sqflite" rel="ugc">Repository (GitHub)</a><br/><a class="link" href="https://github.com/tekartik/sqflite/issues" rel="ugc">View/report issues</a><br/></p><h3 class="title">Topics</h3><p><a href="/packages?q=topic%3Asql" rel="nofollow">#sql</a> <a href="/packages?q=topic%3Adatabase" rel="nofollow">#database</a></p><h3 class="title">Documentation</h3><p><a class="link" href="/documentation/sqflite/latest/">API reference</a><br/></p><h3 class="title">Funding</h3><p>Consider supporting this project:<br/><br/><a class="link" href="https://github.com/sponsors/alextekartik" rel="ugc">github.com</a><br/></p><h3 class="title">License</h3><p><img class="inline-icon-img filter-invert-on-dark" src="/static/hash-o6oemknr/img/material-icon-balance.svg" alt="" width="14" height="14" role="presentation"/>BSD-2-Clause (<a href="/packages/sqflite/license">license</a>)</p><h3 class="title">Dependencies</h3><p><a href="https://api.flutter.dev/">flutter</a>, <a href="/packages/path" title=">=1.8.0 <3.0.0">path</a>, <a href="/packages/sqflite_android" title=">=2.4.0-1 <4.0.0">sqflite_android</a>, <a href="/packages/sqflite_common" title=">=2.5.0-1 <4.0.0">sqflite_common</a>, <a href="/packages/sqflite_darwin" title=">=2.4.1 <4.0.0">sqflite_darwin</a>, <a href="/packages/sqflite_platform_interface" title=">=2.4.0-0 <4.0.0">sqflite_platform_interface</a></p><h3 class="title">More</h3><p><a href="/packages?q=dependency%3Asqflite" rel="nofollow">Packages that depend on sqflite</a></p></div><p class="detail-lead-back"><a class="detail-metadata-toggle">Back</a></p></div><div id="-screenshot-carousel" class="carousel"><fab id="-carousel-prev" class="mdc-fab carousel-prev carousel-nav" data-mdc-auto-init="MDCRipple" title="Previous" data-ga-click-event="screenshot-carousel-prev-click" tabindex="0"><div class="mdc-fab__ripple"></div><img class="mdc-fab__icon" src="/static/hash-o6oemknr/img/keyboard_arrow_left.svg" alt="previous" width="24" height="24" aria-hidden="true"/></fab><div id="-image-container" class="image-container"></div><fab id="-carousel-next" class="mdc-fab carousel-next carousel-nav" data-mdc-auto-init="MDCRipple" title="Next" data-ga-click-event="screenshot-carousel-next-click" tabindex="0"><div class="mdc-fab__ripple"></div><img class="mdc-fab__icon" src="/static/hash-o6oemknr/img/keyboard_arrow_right.svg" alt="next" width="24" height="24" aria-hidden="true"/></fab><p id="-screenshot-description" class="screenshot-description"></p></div></main><footer class="site-footer"><a class="link" href="https://dart.dev/">Dart language</a><a class="link sep" href="/report?subject=package%3Asqflite&url=https%3A%2F%2Fpub.dev%2Fpackages%2Fsqflite">Report package</a><a class="link sep" href="/policy">Policy</a><a class="link sep" href="https://www.google.com/intl/en/policies/terms/">Terms</a><a class="link sep" href="https://developers.google.com/terms/">API Terms</a><a class="link sep" href="/security">Security</a><a class="link sep" href="https://www.google.com/intl/en/policies/privacy/">Privacy</a><a class="link sep" href="/help">Help</a><a class="link icon sep" href="/feed.atom"><img class="inline-icon" src="/static/hash-o6oemknr/img/rss-feed-icon.svg" alt="RSS" width="20" height="20" title="RSS/atom feed"/></a><a class="link icon github_issue" href="https://github.com/dart-lang/pub-dev/issues/new"><img class="inline-icon" src="/static/hash-o6oemknr/img/bug-report-white-96px.png" alt="bug report" width="20" height="20" title="Report an issue with this site"/></a></footer><script src="/static/hash-o6oemknr/highlight/highlight-with-init.js" defer="defer"></script></body></html>