flutter_sqlcipher 0.2.0

  • README.md
  • Example
  • Installing
  • Versions
  • 83

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.

Features #

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

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

Compatibility #

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

Examples #

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);

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).

Some of the android.database.sqlite API methods are 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.

Caveats #

  • 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.

Reference #

sqlite #

import 'package:flutter_sqlcipher/sqlite.dart';

sqlcipher #

import 'package:flutter_sqlcipher/sqlcipher.dart';

See Also #

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

Changelog #

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.2.0 - 2018-12-01

Changed #

  • Upgraded from SQLCipher 3.5.9 to 4.0.0

0.1.6 - 2018-11-30

Added #

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

0.1.5 - 2018-11-30

Added #

  • 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

Added #

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

Changed #

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

0.1.3 - 2018-11-29

Added #

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

0.1.2 - 2018-11-23

Added #

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

Changed #

  • Added an optional parameter to SQLiteDatabase#execSQL()

0.1.1 - 2018-11-23

Added #

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

0.1.0 - 2018-11-22

Added #

  • 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


flutter_sqlcipher_example #

Demonstrates how to use the flutter_sqlcipher plugin.

Getting Started #

For help getting started with Flutter, view our online documentation.

Use this package as a library

1. Depend on it

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

  flutter_sqlcipher: ^0.2.0

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub 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.4.3 Apr 23, 2019 Go to the documentation of flutter_sqlcipher 0.4.3 Download flutter_sqlcipher 0.4.3 archive
0.4.2 Mar 13, 2019 Go to the documentation of flutter_sqlcipher 0.4.2 Download flutter_sqlcipher 0.4.2 archive
0.4.1 Feb 28, 2019 Go to the documentation of flutter_sqlcipher 0.4.1 Download flutter_sqlcipher 0.4.1 archive
0.4.0 Feb 14, 2019 Go to the documentation of flutter_sqlcipher 0.4.0 Download flutter_sqlcipher 0.4.0 archive
0.3.5 Jan 25, 2019 Go to the documentation of flutter_sqlcipher 0.3.5 Download flutter_sqlcipher 0.3.5 archive
0.3.4 Jan 25, 2019 Go to the documentation of flutter_sqlcipher 0.3.4 Download flutter_sqlcipher 0.3.4 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

All 30 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 May 22, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.3.1
  • pana: 0.12.16
  • Flutter: 1.5.4-hotfix.2


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.1.13 0.1.14 0.4.0
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