flutter_sqlcipher 0.3.3

  • README.md
  • Example
  • Installing
  • Versions
  • 79

SQLCipher Database for Flutter

Project license Pub package Dartdoc reference Travis CI build status

This is a Flutter plugin that bundles and wraps SQLCipher for Android, an open-source extension to SQLite that provides transparent 256-bit AES encryption of database files.


  • Implements fully-encrypted SQLite databases stored on disk or in memory.

  • Supports booleans, doubles, integers, strings, blobs, and timestamps.

  • Provides a high-fidelity subset of the android.database.sqlite API to aid Android developers migrating to Flutter.

  • Facilitates porting existing Android database code to Flutter.


Android only, at present. (iOS support is planned.)


Querying an in-memory database

This example also uses DatabaseUtils from the flutter_android package.

import 'package:flutter_sqlcipher/sqlite.dart';
import 'package:flutter_android/android_database.dart' show DatabaseUtils;

var db = await SQLiteDatabase.createInMemory();

var cursor = await db.rawQuery("SELECT 1 AS a, 2 as b, 3 AS c");

await DatabaseUtils.dumpCursor(cursor);

Iterating the rows in a returned cursor

for (var row in await db.rawQuery("SELECT 1 AS a, 2 as b, 3 AS c")) {
  print(row); // prints: {a: 1, b: 2, c: 3}

Using a bundled database from the app's assets


Frequently Asked Questions

Which releases of SQLite and SQLCipher does this plugin bundle?

SQLCipher for Android 4.0.0, SQLCipher 4.0.0, and SQLite 3.25.2.

Why this plugin instead of wrapping Android's native SQLite support?

Two good reasons are:

  1. Encryption. Android's native SQLite support does not feature database encryption. By using this plugin, you can trivially enable encryption for your app database, something likely appreciated by both you as well as your users.

  2. Compatibility. Android's native SQLite version varies greatly depending on the specific Android release, from SQLite 3.4 (released in 2007) to SQLite 3.19 (released in 2017, bundled in Android 8.1). Further, some device manufacturers include different versions of SQLite on their devices. By using this plugin, you gain a consistent, predictable, and up-to-date version of SQLite for your app regardless of the Android release your app runs on.

How much does using this plugin increase my final app size?

Due to the bundled SQLCipher native libraries, your final APK size currently increases by about 6.7 MiB. We are actively investigating ways to reduce that footprint. (e.g., pruning .so files and using ProGuard).

Why are some of the android.database.sqlite API methods missing?

We don't generally implement methods deprecated in the current Android API level. For example, the SQLiteDatabase#isDbLockedByOtherThreads() method was deprecated long ago (in Android 4.1), so we have omitted it from the Dart interface when implementing this plugin.


  • At present, iOS is not supported. This may eventually be addressed going forward by bundling and wrapping FMDB which includes SQLCipher support.

  • At present, cursors are fully materialized. This means that queries which return very large result sets will incur nontrivial overhead in the IPC transfer of the cursor data from Java to Dart. We are planning on adding windowed cursor and streaming support in a future major release. In the meanwhile, OFFSET and LIMIT are your friends.



import 'package:flutter_sqlcipher/sqlcipher.dart';


import 'package:flutter_sqlcipher/sqlite.dart';


Datatype Mappings

Dart ClassDart APISQLite Storage ClassNotes
boolSQLiteCursor#getBool()INTEGER0, 1
DateTimeSQLiteCursor#getDateTime()TEXTISO-8601 "YYYY-MM-DD HH:MM:SS.SSS"
DateTimeSQLiteCursor#getDateTime()INTEGERSeconds since 1970-01-01T00:00:00Z

See Also

  • The sql_builder package that implements a fluent interface for constructing SQL queries.


All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

0.3.3 - 2019-01-21


  • Added a default value for the bindings argument in SQLiteDatabase#execSQL()
  • Added a default value for the bindings argument in SQLiteDatabase#rawQuery()

0.3.2 - 2018-12-08


  • Made SQLiteCursor iterable

0.3.1 - 2018-12-06


  • Fixed Future<dynamic> cast errors in several methods

0.3.0 - 2018-12-05


  • SQLiteCursor#getBlob() now returns a Uint8List, not a ByteBuffer

0.2.5 - 2018-12-05


  • SQLiteDatabase#updateWithOnConflict() method

0.2.4 - 2018-12-04


  • SQLiteDatabase#insertOrThrow() method
  • SQLiteDatabase#insertWithOnConflict() method
  • SQLiteDatabase#replaceOrThrow() method

0.2.3 - 2018-12-04


  • SQLiteDatabase#delete() method
  • SQLiteDatabase#insert() method
  • SQLiteDatabase#replace() method
  • SQLiteDatabase#update() method

0.2.2 - 2018-12-04


  • SQLiteDatabase#setForeignKeyConstraintsEnabled() method
  • SQLiteDatabase#query() method

0.2.1 - 2018-12-03


  • SQLiteDatabase#disableWriteAheadLogging() method
  • SQLiteDatabase#enableWriteAheadLogging() method

0.2.0 - 2018-12-01


  • Upgraded from SQLCipher 3.5.9 to 4.0.0

0.1.6 - 2018-11-30


  • SQLiteClosable interface
  • SQLiteCursor#getBool() method
  • SQLiteDatabase#close() method

0.1.5 - 2018-11-30


  • SQLiteCursor#getDateTime() method
  • SQLiteDatabase#isDatabaseIntegrityOk getter
  • SQLiteDatabase#isDbLockedByCurrentThread getter
  • SQLiteDatabase#getAttachedDbs() method
  • SQLiteDatabase#validateSql() method
  • SQLiteDatabase#yieldIfContendedSafely() method
  • SQLiteDatatypeMismatchException exception

0.1.4 - 2018-11-30


  • SQLiteDatabase#setMaxSqlCacheSize() method
  • SQLiteDatabase#setMaximumSize() method
  • SQLiteDatabase#setPageSize() method


  • Made the second parameter to SQLiteDatabase#rawQuery() optional

0.1.3 - 2018-11-29


  • SQLiteDatabase.releaseMemory() method
  • SQLiteDatabase#setTransactionSuccessful() method
  • SQLiteDatabase#setVersion() method

0.1.2 - 2018-11-23


  • SQLiteDatabase#inTransaction getter
  • SQLiteDatabase#maximumSize getter
  • SQLiteDatabase#pageSize getter
  • SQLiteDatabase#getMaximumSize() method
  • SQLiteDatabase#getPageSize() method
  • SQLiteDatabase#needUpgrade() method


  • Added an optional parameter to SQLiteDatabase#execSQL()

0.1.1 - 2018-11-23


  • SQLiteDatabase#beginTransaction() method
  • SQLiteDatabase#beginTransactionNonExclusive() method
  • SQLiteDatabase#endTransaction() method

0.1.0 - 2018-11-22


  • SQLCipher.version getter
  • SQLite.version getter
  • SQLiteCursor class and methods
  • SQLiteDatabase class
  • SQLiteDatabase.* constants
  • SQLiteDatabase.create() method
  • SQLiteDatabase.createInMemory() method
  • SQLiteDatabase.deleteDatabase() method
  • SQLiteDatabase.openDatabase() method
  • SQLiteDatabase.openOrCreateDatabase() method
  • SQLiteDatabase#path getter
  • SQLiteDatabase#version getter
  • SQLiteDatabase#execSQL() method
  • SQLiteDatabase#getPath() method
  • SQLiteDatabase#getVersion() method
  • SQLiteDatabase#isOpen getter
  • SQLiteDatabase#isReadOnly getter
  • SQLiteDatabase#isWriteAheadLoggingEnabled getter
  • SQLiteDatabase#rawQuery() method
  • SQLiteDatabase#setLocale() method



Demonstrates how to use the flutter_sqlcipher plugin.



Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  flutter_sqlcipher: ^0.3.3

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:flutter_sqlcipher/sqlcipher.dart';
import 'package:flutter_sqlcipher/sqlite.dart';
Version Uploaded Documentation Archive
0.3.3 Jan 21, 2019 Go to the documentation of flutter_sqlcipher 0.3.3 Download flutter_sqlcipher 0.3.3 archive
0.3.2 Dec 8, 2018 Go to the documentation of flutter_sqlcipher 0.3.2 Download flutter_sqlcipher 0.3.2 archive
0.3.1 Dec 6, 2018 Go to the documentation of flutter_sqlcipher 0.3.1 Download flutter_sqlcipher 0.3.1 archive
0.3.0 Dec 5, 2018 Go to the documentation of flutter_sqlcipher 0.3.0 Download flutter_sqlcipher 0.3.0 archive
0.2.5 Dec 5, 2018 Go to the documentation of flutter_sqlcipher 0.2.5 Download flutter_sqlcipher 0.2.5 archive
0.2.4 Dec 4, 2018 Go to the documentation of flutter_sqlcipher 0.2.4 Download flutter_sqlcipher 0.2.4 archive
0.2.3 Dec 4, 2018 Go to the documentation of flutter_sqlcipher 0.2.3 Download flutter_sqlcipher 0.2.3 archive
0.2.2 Dec 4, 2018 Go to the documentation of flutter_sqlcipher 0.2.2 Download flutter_sqlcipher 0.2.2 archive
0.2.1 Dec 3, 2018 Go to the documentation of flutter_sqlcipher 0.2.1 Download flutter_sqlcipher 0.2.1 archive
0.2.0 Dec 1, 2018 Go to the documentation of flutter_sqlcipher 0.2.0 Download flutter_sqlcipher 0.2.0 archive

All 24 versions...

Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jan 21, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.10
  • Flutter: 1.1.7


Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Fix lib/src/program.dart. (-1 points)

Analysis of lib/src/program.dart reported 2 hints:

line 10 col 3: The class 'Future' was not exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

line 11 col 12: The class 'Future' was not exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

Format lib/sqlcipher.dart.

Run flutter format to format lib/sqlcipher.dart.

Format lib/sqlite.dart.

Run flutter format to format lib/sqlite.dart.

Fix additional 3 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/src/cursor.dart (Run flutter format to format lib/src/cursor.dart.)
  • lib/src/database.dart (Run flutter format to format lib/src/database.dart.)
  • lib/src/query.dart (Run flutter format to format lib/src/query.dart.)


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
flutter 0.0.0
flutter_android ^0.2.3 0.2.3
meta ^1.1.6 1.1.6 1.1.7
Transitive dependencies
collection 1.14.11
platform 2.2.0
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
test >=1.3.4 <2.0.0