├── .gitignore
├── .travis.yml
├── LICENSE
├── README.md
├── analysis_options.yaml
├── pubspec.yaml
├── sqflite
├── .gitignore
├── CHANGELOG.md
├── LICENSE
├── README.md
├── analysis_options.yaml
├── android
│ ├── .gitignore
│ ├── build.gradle
│ ├── gradle.properties
│ ├── settings.gradle
│ └── src
│ │ └── main
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ └── com
│ │ └── davidmartos96
│ │ └── sqflite_sqlcipher
│ │ ├── Constant.java
│ │ ├── Database.java
│ │ ├── LogLevel.java
│ │ ├── SqfliteSqlCipherPlugin.java
│ │ ├── SqlCommand.java
│ │ ├── dev
│ │ └── Debug.java
│ │ └── operation
│ │ ├── BaseOperation.java
│ │ ├── BaseReadOperation.java
│ │ ├── BatchOperation.java
│ │ ├── ExecuteOperation.java
│ │ ├── MethodCallOperation.java
│ │ ├── Operation.java
│ │ ├── OperationResult.java
│ │ └── SqlErrorInfo.java
├── example
│ ├── .gitignore
│ ├── README.md
│ ├── analysis_options.yaml
│ ├── android
│ │ ├── .gitignore
│ │ ├── app
│ │ │ ├── build.gradle
│ │ │ ├── proguard-rules.pro
│ │ │ └── src
│ │ │ │ ├── debug
│ │ │ │ └── AndroidManifest.xml
│ │ │ │ ├── main
│ │ │ │ ├── AndroidManifest.xml
│ │ │ │ ├── kotlin
│ │ │ │ │ └── com
│ │ │ │ │ │ └── davidmartos96
│ │ │ │ │ │ └── example
│ │ │ │ │ │ └── MainActivity.kt
│ │ │ │ └── res
│ │ │ │ │ ├── drawable-v21
│ │ │ │ │ └── launch_background.xml
│ │ │ │ │ ├── drawable
│ │ │ │ │ └── launch_background.xml
│ │ │ │ │ ├── mipmap-hdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ │ ├── mipmap-mdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ │ ├── mipmap-xhdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ │ ├── mipmap-xxhdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ │ ├── mipmap-xxxhdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ │ ├── values-night
│ │ │ │ │ └── styles.xml
│ │ │ │ │ └── values
│ │ │ │ │ └── styles.xml
│ │ │ │ └── profile
│ │ │ │ └── AndroidManifest.xml
│ │ ├── build.gradle
│ │ ├── gradle.properties
│ │ ├── gradle
│ │ │ └── wrapper
│ │ │ │ └── gradle-wrapper.properties
│ │ └── settings.gradle
│ ├── assets
│ │ ├── example.db
│ │ ├── example_pass_1234.db
│ │ ├── issue_64.db
│ │ └── sqlcipher-3.0-testkey.db
│ ├── ios
│ │ ├── .gitignore
│ │ ├── Flutter
│ │ │ ├── AppFrameworkInfo.plist
│ │ │ ├── Debug.xcconfig
│ │ │ └── Release.xcconfig
│ │ ├── Runner.xcodeproj
│ │ │ ├── project.pbxproj
│ │ │ └── xcshareddata
│ │ │ │ └── xcschemes
│ │ │ │ └── Runner.xcscheme
│ │ ├── Runner
│ │ │ ├── AppDelegate.swift
│ │ │ ├── Assets.xcassets
│ │ │ │ ├── AppIcon.appiconset
│ │ │ │ │ ├── Contents.json
│ │ │ │ │ ├── Icon-App-1024x1024@1x.png
│ │ │ │ │ ├── Icon-App-20x20@1x.png
│ │ │ │ │ ├── Icon-App-20x20@2x.png
│ │ │ │ │ ├── Icon-App-20x20@3x.png
│ │ │ │ │ ├── Icon-App-29x29@1x.png
│ │ │ │ │ ├── Icon-App-29x29@2x.png
│ │ │ │ │ ├── Icon-App-29x29@3x.png
│ │ │ │ │ ├── Icon-App-40x40@1x.png
│ │ │ │ │ ├── Icon-App-40x40@2x.png
│ │ │ │ │ ├── Icon-App-40x40@3x.png
│ │ │ │ │ ├── Icon-App-60x60@2x.png
│ │ │ │ │ ├── Icon-App-60x60@3x.png
│ │ │ │ │ ├── Icon-App-76x76@1x.png
│ │ │ │ │ ├── Icon-App-76x76@2x.png
│ │ │ │ │ └── Icon-App-83.5x83.5@2x.png
│ │ │ │ └── LaunchImage.imageset
│ │ │ │ │ ├── Contents.json
│ │ │ │ │ ├── LaunchImage.png
│ │ │ │ │ ├── LaunchImage@2x.png
│ │ │ │ │ ├── LaunchImage@3x.png
│ │ │ │ │ └── README.md
│ │ │ ├── Base.lproj
│ │ │ │ ├── LaunchScreen.storyboard
│ │ │ │ └── Main.storyboard
│ │ │ ├── Info.plist
│ │ │ └── Runner-Bridging-Header.h
│ │ └── RunnerTests
│ │ │ └── RunnerTests.swift
│ ├── lib
│ │ ├── batch_test_page.dart
│ │ ├── database
│ │ │ └── database.dart
│ │ ├── deprecated_test_page.dart
│ │ ├── exception_test_page.dart
│ │ ├── exp_test_page.dart
│ │ ├── main.dart
│ │ ├── manual_test_page.dart
│ │ ├── model
│ │ │ ├── item.dart
│ │ │ ├── main_item.dart
│ │ │ └── test.dart
│ │ ├── open_test_page.dart
│ │ ├── raw_test_page.dart
│ │ ├── slow_test_page.dart
│ │ ├── sqlcipher_test_page.dart
│ │ ├── src
│ │ │ ├── common_import.dart
│ │ │ ├── dev_utils.dart
│ │ │ ├── expect.dart
│ │ │ ├── item_widget.dart
│ │ │ └── main_item_widget.dart
│ │ ├── test_page.dart
│ │ ├── todo_test_page.dart
│ │ ├── type_test_page.dart
│ │ └── utils.dart
│ ├── macos
│ │ ├── .gitignore
│ │ ├── Flutter
│ │ │ ├── Flutter-Debug.xcconfig
│ │ │ ├── Flutter-Release.xcconfig
│ │ │ └── GeneratedPluginRegistrant.swift
│ │ ├── Runner.xcodeproj
│ │ │ ├── project.pbxproj
│ │ │ └── xcshareddata
│ │ │ │ └── xcschemes
│ │ │ │ └── Runner.xcscheme
│ │ ├── Runner
│ │ │ ├── AppDelegate.swift
│ │ │ ├── Assets.xcassets
│ │ │ │ └── AppIcon.appiconset
│ │ │ │ │ ├── Contents.json
│ │ │ │ │ ├── app_icon_1024.png
│ │ │ │ │ ├── app_icon_128.png
│ │ │ │ │ ├── app_icon_16.png
│ │ │ │ │ ├── app_icon_256.png
│ │ │ │ │ ├── app_icon_32.png
│ │ │ │ │ ├── app_icon_512.png
│ │ │ │ │ └── app_icon_64.png
│ │ │ ├── Base.lproj
│ │ │ │ └── MainMenu.xib
│ │ │ ├── Configs
│ │ │ │ ├── AppInfo.xcconfig
│ │ │ │ ├── Debug.xcconfig
│ │ │ │ ├── Release.xcconfig
│ │ │ │ └── Warnings.xcconfig
│ │ │ ├── DebugProfile.entitlements
│ │ │ ├── Info.plist
│ │ │ ├── MainFlutterWindow.swift
│ │ │ └── Release.entitlements
│ │ └── RunnerTests
│ │ │ └── RunnerTests.swift
│ ├── pubspec.yaml
│ ├── test
│ │ ├── database_test.dart
│ │ ├── main
│ │ │ └── test_main.dart
│ │ ├── model_test.dart
│ │ └── sqflite_e2e.dart
│ ├── test_driver
│ │ ├── main.dart
│ │ ├── main_test.dart
│ │ ├── sqflite_e2e.dart
│ │ ├── sqflite_e2e_test.dart
│ │ ├── sqflite_impl_test.dart
│ │ └── sqflite_test.dart
│ └── tool
│ │ ├── android_sqflite_logcat.dart
│ │ ├── android_uninstall.dart
│ │ ├── run_e2e_test.dart
│ │ ├── run_flutter_driver_test.dart
│ │ └── travis.dart
├── ios
│ ├── .gitignore
│ ├── Assets
│ │ └── .gitkeep
│ ├── Classes
│ │ ├── SqfliteSqlCipherOperation.h
│ │ ├── SqfliteSqlCipherOperation.m
│ │ ├── SqfliteSqlCipherPlugin.h
│ │ └── SqfliteSqlCipherPlugin.m
│ ├── Resources
│ │ └── PrivacyInfo.xcprivacy
│ └── sqflite_sqlcipher.podspec
├── lib
│ ├── sqflite.dart
│ ├── sql.dart
│ ├── sqlite_api.dart
│ └── src
│ │ ├── database_sql_cipher_impl.dart
│ │ ├── factory_sql_cipher_impl.dart
│ │ ├── sqflite_import.dart
│ │ ├── sqflite_sql_cipher_impl.dart
│ │ ├── sql_cipher_constant.dart
│ │ └── sql_cipher_open_options.dart
├── macos
│ ├── Classes
│ │ ├── SqfliteSqlCipherOperation.h
│ │ ├── SqfliteSqlCipherOperation.m
│ │ ├── SqfliteSqlCipherPlugin.h
│ │ └── SqfliteSqlCipherPlugin.m
│ ├── Resources
│ │ └── PrivacyInfo.xcprivacy
│ └── sqflite_sqlcipher.podspec
├── pubspec.yaml
└── test
│ └── sqflite_sql_cipher_open_test.dart
└── tool
├── copy_macos_code_to_ios.dart
├── run_test.dart
├── tag.dart
└── travis.dart
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://www.dartlang.org/guides/libraries/private-files
2 |
3 | # Files and directories created by pub
4 | .dart_tool/
5 | .packages
6 | .pub/
7 | build/
8 | # If you're building an application, you may want to check-in your pubspec.lock
9 | pubspec.lock
10 |
11 | # Directory created by dartdoc
12 | /doc/api/
13 |
14 | # flutter root folder wrongly created
15 | /ios
16 | /android
17 | .symlinks
18 |
19 | # IDE
20 | .idea/
21 | *.iml
22 | .vscode/
23 | /sqflite/example/.flutter-plugins-dependencies
24 |
25 | # Copied from flutter plugins
26 | .DS_Store
27 | .atom/
28 | flutter_export_environment.sh
29 |
30 | Podfile
31 | Podfile.lock
32 | Pods/
33 | .symlinks/
34 | **/Flutter/App.framework/
35 | **/Flutter/Flutter.framework/
36 | **/Flutter/Generated.xcconfig
37 | **/Flutter/flutter_assets/
38 | ServiceDefinitions.json
39 | xcuserdata/
40 | *.xcworkspace
41 | **/DerivedData/
42 |
43 | local.properties
44 | keystore.properties
45 | .gradle/
46 | gradlew
47 | gradlew.bat
48 | gradle-wrapper.jar
49 | .flutter-plugins-dependencies
50 |
51 | GeneratedPluginRegistrant.h
52 | GeneratedPluginRegistrant.m
53 | GeneratedPluginRegistrant.java
54 | .flutter-plugins
55 |
56 | .project
57 | .classpath
58 | .settings
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: dart
2 | sudo: required
3 | dist: trusty
4 | dart:
5 | - stable
6 | - dev
7 | before_script:
8 | - pub run tekartik_travis_ci_flutter:install
9 | - source $(pub run tekartik_travis_ci_flutter:env)
10 | script:
11 | - dart tool/travis.dart
12 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | BSD 2-Clause License
2 |
3 | Copyright (c) 2019, Tekartik
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | * Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | * Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # sqflite_sqlcipher
2 |
3 | #### Package description and instructions: [Here](https://github.com/davidmartos96/sqflite_sqlcipher/blob/master/sqflite/README.md)
--------------------------------------------------------------------------------
/analysis_options.yaml:
--------------------------------------------------------------------------------
1 | # Defines a default set of lint rules enforced for
2 | # projects at Google. For details and rationale,
3 | # see https://github.com/dart-lang/pedantic#enabled-lints.
4 | include: package:pedantic/analysis_options.yaml
5 |
6 | analyzer:
7 | strong-mode:
8 | implicit-casts: false
9 |
10 | errors:
11 | # treat missing required parameters as a warning (not a hint)
12 | missing_required_param: warning
13 | # treat missing returns as a warning (not a hint)
14 | missing_return: warning
15 | # allow having TODOs in the code
16 | todo: ignore
17 | # Ignore errors like
18 | # 'super_goes_last' is a deprecated lint rule and should not be used • included_file_warning
19 | included_file_warning: ignore
20 |
--------------------------------------------------------------------------------
/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: sqflite_sqlcipher_repo
2 | description: Sqflite SqlCipher repo
3 | version: 0.1.0
4 | homepage: https://github.com/davidmartos96/sqflite_sqlcipher
5 | publish_to: none
6 |
7 | environment:
8 | sdk: '>=2.4.0-dev <3.0.0'
9 |
10 | dev_dependencies:
11 | pedantic: '>=1.4.0 <3.0.0'
12 | tekartik_travis_ci_flutter:
13 | git:
14 | url: git://github.com/tekartik/travis_ci_flutter.dart
15 | ref: dart2
16 | version: '>=0.1.0'
17 | process_run: '>=0.10.6'
18 |
19 | dependency_overrides:
20 | pedantic: '>=1.9.0 <3.0.0'
21 |
--------------------------------------------------------------------------------
/sqflite/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .packages
3 | .pub/
4 | ios/.generated/
5 | packages
6 | pubspec.lock
7 |
8 | # Directory created by dartdoc
9 | doc/api/
10 |
11 | # Local folder
12 | .local/
13 |
14 | # local flutter install (travis)
15 | flutter
16 |
17 | # Conventional directory for build outputs
18 | build/
19 | coverage/
20 |
21 | # flutter
22 | .metadata
--------------------------------------------------------------------------------
/sqflite/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## 3.1.0
2 | * Update SQLCipher version to [4.5.7](https://www.zetetic.net/blog/2024/04/24/sqlcipher-4.5.7-release/)
3 |
4 | ## 3.0.0
5 | * Update SQLCipher version to [4.5.6](https://www.zetetic.net/blog/2024/01/17/sqlcipher-4.5.6-release/)
6 | * Android minimum required SDK 21 and use `compileSdk` 34.
7 | * Ensure the provided password is valid when opening the database. This now makes it possible to differentiate between failing to cipher_migrate and opening a database with the wrong password.
8 | * On iOS/macOS, if you have sqflite as a transitive dependency with version 2.3.2 or greater, the `fmdb_override` workaround in the `dependency_overrides` is not needed anymore.
9 | * Add iOS/MacOS privacy manifest
10 | * Dart >= 3.3.0
11 |
12 | ## 2.2.1
13 | * Update minimum deployment targets for iOS (11.0) and macOS (10.13) to use SQLCipher 4.5.4
14 |
15 | ## 2.2.0
16 | * SQLCipher version 4.5.4
17 |
18 | ## 2.1.1
19 | * SQLCipher version 4.5.0
20 | * Update Android build version
21 | * Update example project
22 |
23 | ## 2.1.0
24 | * Remove references to deprecated android plugin embedding v1
25 |
26 | ## 2.0.0
27 | * Stable version with NNBD support
28 |
29 | ## 2.0.0-nullsafety.0
30 | * NNBD support
31 |
32 | ## 1.1.4
33 |
34 | * Update names in ios native implementation to avoid conflicts with the `sqflite` package
35 |
36 | ## 1.1.3
37 |
38 | * Update SQLCipher version to [4.4.2](https://www.zetetic.net/blog/2020/11/25/sqlcipher-442-release/)
39 |
40 | ## 1.1.2
41 |
42 | * Update SQLCipher version to [4.4.1](https://www.zetetic.net/blog/2020/11/06/sqlcipher-441-release/)
43 | * Fix Handler constructor deprecation
44 |
45 | ## 1.1.1
46 |
47 | * Remove unnecessary logs
48 |
49 | ## 1.1.0+1
50 |
51 | * Update SQLCipher version to [4.4.0](https://www.zetetic.net/blog/2020/05/12/sqlcipher-440-release/)
52 |
53 | ## 1.0.0+6
54 |
55 | * Initial package release, using `sqflite_common` as a dependency under the hood.
56 |
--------------------------------------------------------------------------------
/sqflite/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2017, Alexandre Roux Tekartik.
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of
4 | this software and associated documentation files (the "Software"), to deal in
5 | the Software without restriction, including without limitation the rights to
6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7 | of the Software, and to permit persons to whom the Software is furnished to do
8 | so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in all
11 | copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | SOFTWARE.
20 |
--------------------------------------------------------------------------------
/sqflite/README.md:
--------------------------------------------------------------------------------
1 | # sqflite_sqlcipher
2 |
3 | [](https://pub.dev/packages/sqflite_sqlcipher)
4 |
5 | This is a fork from the plugin [sqflite](https://github.com/tekartik/sqflite).
6 |
7 | **[sqflite_common version 1.0.0](https://pub.dev/packages/sqflite_common)**
8 |
9 | This fork makes use of the Dart package `sqflite_common` but with a native implementation which uses the SqlCipher library on both iOS and Android. The API is the same as the `sqflite` plugin, only that the `openDatabase` method includes an optional parameter `password`.
10 |
11 | The SQLCipher version of the plugin is 4.x If you try to open a database encrypted with a lower version of SQLCipher, the plugin will try to migrate it to a new version using the operation `PRAGMA cipher_migrate` (This automatic migration to version 4 is only done in Android. PR welcome for this feature in iOS).
12 |
13 | ### Install and use
14 |
15 | To add it in your project include this in the `pubspec.yml`.
16 | ```
17 | dependencies:
18 | sqflite_sqlcipher: {latest version}
19 | ```
20 |
21 | ```dart
22 | import 'package:sqflite_sqlcipher/sqflite.dart';
23 |
24 | Database db = await openDatabase(
25 | path,
26 | password: "my password",
27 | // onCreate, onUpgrade...
28 | );
29 | ```
30 |
31 | ### Android
32 | **REQUIRED:** Flutter now enables code shrinking by default when building an APK in release mode, so you need to add the following ProGuard rules to the file `android/app/proguard-rules.pro`. If it does not exist, create it:
33 |
34 | ```
35 | -keep class net.sqlcipher.** { *; }
36 | ```
37 |
38 | ### If using `sqflite` version < 2.3.2 as direct or transitive dependency
39 |
40 | If you use sqflite v2.3.2 or greater you can ignore this, because it doesn't use the `FMDB` pod anymore.
41 |
42 | If any of your project's dependencies uses sqflite (e.g: cached_network_image, flutter_cache_manager...), then for iOS to link correctly the SQLCipher libraries you need to override it in your `pubspec.yaml` file:
43 |
44 | ```yaml
45 | dependency_overrides:
46 | sqflite:
47 | git:
48 | url: https://www.github.com/davidmartos96/sqflite_sqlcipher.git
49 | path: sqflite
50 | ref: fmdb_override
51 | ```
52 |
53 | The reason for this is that in iOS, the `FMDB` and `FMDB/SQLCipher` pods cannot be used at the same time. The override only changes that reference. The rest is the full `sqflite` package.
54 | If anyone knows about a better way to handle this, PRs are welcome :D
55 |
56 |
57 | ---
58 |
59 | ## Sqflite documentation
60 |
61 | * [Documentation](https://github.com/tekartik/sqflite/blob/master/sqflite/README.md)
62 |
--------------------------------------------------------------------------------
/sqflite/analysis_options.yaml:
--------------------------------------------------------------------------------
1 | # Defines a default set of lint rules enforced for
2 | # projects at Google. For details and rationale,
3 | # see https://github.com/dart-lang/pedantic#enabled-lints.
4 | include: package:lints/recommended.yaml
5 |
6 | analyzer:
7 | strong-mode:
8 | implicit-casts: false
9 | # implicit-dynamic: false
10 |
11 | errors:
12 | # treat missing required parameters as a warning (not a hint)
13 | missing_required_param: warning
14 | # treat missing returns as a warning (not a hint)
15 | missing_return: warning
16 | # allow having TODOs in the code
17 | todo: ignore
18 | # Ignore errors like
19 | # 'super_goes_last' is a deprecated lint rule and should not be used • included_file_warning
20 | included_file_warning: ignore
21 |
22 | linter:
23 | rules:
24 | # these rules are documented on and in the same order as
25 | # the Dart Lint rules page to make maintenance easier
26 | # http://dart-lang.github.io/linter/lints/
27 |
28 | # === error rules ===
29 | - avoid_empty_else
30 | - avoid_slow_async_io
31 | - cancel_subscriptions
32 | # - close_sinks # https://github.com/flutter/flutter/issues/5789
33 | # - comment_references # blocked on https://github.com/dart-lang/dartdoc/issues/1153
34 | - control_flow_in_finally
35 | - empty_statements
36 | - hash_and_equals
37 | # - invariant_booleans # https://github.com/flutter/flutter/issues/5790
38 | # - literal_only_boolean_expressions # https://github.com/flutter/flutter/issues/5791
39 | - no_adjacent_strings_in_list
40 | - no_duplicate_case_values
41 | - test_types_in_equals
42 | - throw_in_finally
43 | - unrelated_type_equality_checks
44 | - valid_regexps
45 |
46 | # === style rules ===
47 | - always_declare_return_types
48 | # - always_put_control_body_on_new_line
49 | # - always_specify_types
50 | - annotate_overrides
51 | # - avoid_annotating_with_dynamic # not yet tested
52 | # - avoid_as # 2019-01-30 removed for no-implicit-casts
53 | # - avoid_catches_without_on_clauses # not yet tested
54 | # - avoid_catching_errors # not yet tested
55 | # - avoid_classes_with_only_static_members # not yet tested
56 | # - avoid_function_literals_in_foreach_calls # not yet tested
57 | - avoid_init_to_null
58 | - avoid_null_checks_in_equality_operators
59 | # - avoid_positional_boolean_parameters # not yet tested
60 | - avoid_return_types_on_setters
61 | # - avoid_returning_null # not yet tested
62 | # - avoid_returning_this # not yet tested
63 | # - avoid_setters_without_getters # not yet tested
64 | # - avoid_types_on_closure_parameters # not yet tested
65 | - await_only_futures
66 | - camel_case_types
67 | # - cascade_invocations # not yet tested
68 | # - constant_identifier_names # https://github.com/dart-lang/linter/issues/204
69 | - directives_ordering
70 | - empty_catches
71 | - empty_constructor_bodies
72 | - implementation_imports
73 | # - join_return_with_assignment # not yet tested
74 | - library_names
75 | - library_prefixes
76 | - non_constant_identifier_names
77 | # - omit_local_variable_types # opposite of always_specify_types
78 | # - one_member_abstracts # too many false positives
79 | # - only_throw_errors # https://github.com/flutter/flutter/issues/5792
80 | - overridden_fields
81 | - package_api_docs
82 | - package_prefixed_library_names
83 | # - parameter_assignments # we do this commonly
84 | - prefer_adjacent_string_concatenation
85 | - prefer_collection_literals
86 | # - prefer_conditional_assignment # not yet tested
87 | - prefer_const_constructors
88 | # - prefer_constructors_over_static_methods # not yet tested
89 | - prefer_contains
90 | # - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods
91 | # - prefer_final_fields # https://github.com/dart-lang/linter/issues/506
92 | - prefer_final_locals
93 | # - prefer_foreach # not yet tested
94 | # - prefer_function_declarations_over_variables # not yet tested
95 | - prefer_initializing_formals
96 | # - prefer_interpolation_to_compose_strings # not yet tested
97 | - prefer_is_empty
98 | - prefer_is_not_empty
99 | - prefer_void_to_null
100 | # - recursive_getters # https://github.com/dart-lang/linter/issues/452
101 | - slash_for_doc_comments
102 | - sort_constructors_first
103 | - sort_unnamed_constructors_first
104 | # - super_goes_last
105 | # - type_annotate_public_apis # subset of always_specify_types
106 | - type_init_formals
107 | # - unawaited_futures # https://github.com/flutter/flutter/issues/5793
108 | - unnecessary_brace_in_string_interps
109 | - unnecessary_const
110 | - unnecessary_getters_setters
111 | # - unnecessary_lambdas # https://github.com/dart-lang/linter/issues/498
112 | - unnecessary_new
113 | - unnecessary_null_aware_assignments
114 | - unnecessary_null_in_if_null_operators
115 | # - unnecessary_overrides # https://github.com/dart-lang/linter/issues/626 and https://github.com/dart-lang/linter/issues/627
116 | - unnecessary_statements
117 | - unnecessary_this
118 | - use_rethrow_when_possible
119 | # - use_setters_to_change_properties # not yet tested
120 | # - use_string_buffers # https://github.com/dart-lang/linter/pull/664
121 | # - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review
122 |
123 | # === pub rules ===
124 | - package_names
125 |
126 | # === doc rules ===
127 | - public_member_api_docs
128 |
--------------------------------------------------------------------------------
/sqflite/android/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 |
10 | /gradle
11 | /gradlew
12 | /gradlew.bat
13 |
--------------------------------------------------------------------------------
/sqflite/android/build.gradle:
--------------------------------------------------------------------------------
1 | group 'com.davidmartos96.sqflite_sqlcipher'
2 | version '1.0-SNAPSHOT'
3 |
4 | buildscript {
5 | repositories {
6 | google()
7 | mavenCentral()
8 | }
9 |
10 | dependencies {
11 | classpath 'com.android.tools.build:gradle:8.3.0'
12 | }
13 | }
14 |
15 | rootProject.allprojects {
16 | repositories {
17 | google()
18 | mavenCentral()
19 | }
20 | }
21 |
22 | apply plugin: 'com.android.library'
23 |
24 | android {
25 | compileSdk 34
26 |
27 | namespace 'com.davidmartos96.sqflite_sqlcipher'
28 |
29 | compileOptions {
30 | sourceCompatibility JavaVersion.VERSION_17
31 | targetCompatibility JavaVersion.VERSION_17
32 | }
33 |
34 | defaultConfig {
35 | minSdk 21
36 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
37 | }
38 | lintOptions {
39 | disable 'InvalidPackage'
40 | }
41 | }
42 |
43 | dependencies {
44 | implementation 'net.zetetic:sqlcipher-android:4.5.7@aar'
45 |
46 | // We need to use a version compatible with sqlcipher. See here:
47 | // https://github.com/sqlcipher/sqlcipher-android/blob/c5bd0cf2a2d26cd977d6127180f594750675093e/build.gradle#L34
48 | implementation 'androidx.sqlite:sqlite:2.3.1'
49 | }
50 |
--------------------------------------------------------------------------------
/sqflite/android/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx1536M
2 |
--------------------------------------------------------------------------------
/sqflite/android/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'sqflite_sqlcipher'
2 |
--------------------------------------------------------------------------------
/sqflite/android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/sqflite/android/src/main/java/com/davidmartos96/sqflite_sqlcipher/Constant.java:
--------------------------------------------------------------------------------
1 | package com.davidmartos96.sqflite_sqlcipher;
2 |
3 | /**
4 | * Constants between dart & Java world
5 | */
6 |
7 | public class Constant {
8 |
9 | // Can be used as the name MethodChannel or to register with
10 | static final public String PLUGIN_KEY = "com.davidmartos96.sqflite_sqlcipher";
11 |
12 | static final public String METHOD_GET_PLATFORM_VERSION = "getPlatformVersion";
13 | static final public String METHOD_GET_DATABASES_PATH = "getDatabasesPath";
14 | static final public String METHOD_DEBUG = "debug";
15 | static final public String METHOD_OPTIONS = "options";
16 | static final public String METHOD_OPEN_DATABASE = "openDatabase";
17 | static final public String METHOD_CLOSE_DATABASE = "closeDatabase";
18 | static final public String METHOD_INSERT = "insert";
19 | static final public String METHOD_EXECUTE = "execute";
20 | static final public String METHOD_QUERY = "query";
21 | static final public String METHOD_UPDATE = "update";
22 | static final public String METHOD_BATCH = "batch";
23 | static final public String METHOD_DELETE_DATABASE = "deleteDatabase";
24 |
25 | static final String PARAM_ID = "id";
26 | static final String PARAM_PATH = "path";
27 | // when opening a database
28 | static final String PARAM_READ_ONLY = "readOnly"; // boolean
29 | static final String PARAM_PASSWORD = "password"; // optional String
30 | static final String PARAM_SINGLE_INSTANCE = "singleInstance"; // boolean
31 | static final String PARAM_LOG_LEVEL = "logLevel"; // int
32 | // true when entering, false when leaving, null otherwise
33 | public static final String PARAM_IN_TRANSACTION = "inTransaction";
34 | // Result when opening a database
35 | public static final String PARAM_RECOVERED = "recovered";
36 | // Result when opening a database
37 | public static final String PARAM_RECOVERED_IN_TRANSACTION = "recoveredInTransaction";
38 |
39 | static final String PARAM_QUERY_AS_MAP_LIST = "queryAsMapList"; // boolean
40 | static final String PARAM_THREAD_PRIORITY = "androidThreadPriority"; // int
41 |
42 | public static final String PARAM_SQL = "sql";
43 | public static final String PARAM_SQL_ARGUMENTS = "arguments";
44 | public static final String PARAM_NO_RESULT = "noResult";
45 | public static final String PARAM_CONTINUE_OR_ERROR = "continueOnError";
46 |
47 | // debugMode
48 | static final String PARAM_CMD = "cmd"; // debugMode cmd: get/set
49 | static final String CMD_GET = "get";
50 |
51 | // in batch
52 | static final String PARAM_OPERATIONS = "operations";
53 | // in each operation
54 | public static final String PARAM_METHOD = "method";
55 |
56 | // Batch operation results
57 | public static final String PARAM_RESULT = "result";
58 | public static final String PARAM_ERROR = "error"; // map with code/message/data
59 | public static final String PARAM_ERROR_CODE = "code";
60 | public static final String PARAM_ERROR_MESSAGE = "message";
61 | public static final String PARAM_ERROR_DATA = "data";
62 |
63 | static final String SQLITE_ERROR = "sqlite_error"; // code
64 | static final String ERROR_BAD_PARAM = "bad_param"; // internal only
65 | static final String ERROR_OPEN_FAILED = "open_failed"; // msg
66 | static final String ERROR_DATABASE_CLOSED = "database_closed"; // msg
67 |
68 | // memory database path
69 | static final String MEMORY_DATABASE_PATH = ":memory:";
70 |
71 | // android log tag
72 | static final public String TAG = "Sqflite";
73 |
74 | // Obsolete since 1.17
75 | static final public String METHOD_DEBUG_MODE = "debugMode";
76 | }
77 |
--------------------------------------------------------------------------------
/sqflite/android/src/main/java/com/davidmartos96/sqflite_sqlcipher/Database.java:
--------------------------------------------------------------------------------
1 | package com.davidmartos96.sqflite_sqlcipher;
2 |
3 | import android.util.Log;
4 |
5 |
6 | import java.io.File;
7 |
8 | import static com.davidmartos96.sqflite_sqlcipher.Constant.TAG;
9 |
10 | import net.zetetic.database.DatabaseErrorHandler;
11 | import net.zetetic.database.sqlcipher.SQLiteConnection;
12 | import net.zetetic.database.sqlcipher.SQLiteDatabase;
13 | import net.zetetic.database.sqlcipher.SQLiteDatabaseHook;
14 |
15 | class Database {
16 | final boolean singleInstance;
17 | final String path;
18 | final String password;
19 | final int id;
20 | final int logLevel;
21 | SQLiteDatabase sqliteDatabase;
22 | boolean inTransaction;
23 |
24 |
25 | Database(String path, String password, int id, boolean singleInstance, int logLevel) {
26 | this.path = path;
27 | this.password = (password != null) ? password : "";
28 |
29 | this.singleInstance = singleInstance;
30 | this.id = id;
31 | this.logLevel = logLevel;
32 | }
33 |
34 | public void open() {
35 | openWithFlags(SQLiteDatabase.CREATE_IF_NECESSARY);
36 |
37 | }
38 |
39 | // Change default error handler to avoid erasing the existing file.
40 | public void openReadOnly() {
41 | openWithFlags(SQLiteDatabase.OPEN_READONLY, new DatabaseErrorHandler() {
42 | @Override
43 | public void onCorruption(SQLiteDatabase dbObj) {
44 | // ignored
45 | // default implementation delete the file
46 | //
47 | // This happens asynchronously so cannot be tracked. However a simple
48 | // access should fail
49 | }
50 | });
51 | }
52 |
53 | private void openWithFlags(int flags) {
54 | openWithFlags(flags, null);
55 | }
56 |
57 | private void openWithFlags(int flags, DatabaseErrorHandler errorHandler) {
58 | try {
59 | sqliteDatabase = SQLiteDatabase.openDatabase(path, password, null, flags, errorHandler, null);
60 |
61 | }catch (Exception e) {
62 | Log.d(TAG, "Opening db in " + path + " with PRAGMA cipher_migrate");
63 | SQLiteDatabaseHook hook = new SQLiteDatabaseHook() {
64 | @Override
65 | public void preKey(SQLiteConnection database) {
66 |
67 | }
68 |
69 | @Override
70 | public void postKey(SQLiteConnection database) {
71 | long migrateRes = database.executeForLong("PRAGMA cipher_migrate;", null, null);
72 |
73 | if (migrateRes != 0) {
74 | // Throw the original exception, assuming a wrong password was provided
75 | throw e;
76 | }
77 | }
78 | };
79 |
80 | sqliteDatabase = SQLiteDatabase.openDatabase(path, password, null, flags, errorHandler, hook);
81 | }
82 | }
83 |
84 | public void close() {
85 | sqliteDatabase.close();
86 | }
87 |
88 | public SQLiteDatabase getWritableDatabase() {
89 | return sqliteDatabase;
90 | }
91 |
92 | public SQLiteDatabase getReadableDatabase() {
93 | return sqliteDatabase;
94 | }
95 |
96 | public boolean enableWriteAheadLogging() {
97 | try {
98 | sqliteDatabase.rawExecSQL("PRAGMA journal_mode=WAL;");
99 | } catch (Exception e) {
100 | Log.e(TAG, getThreadLogPrefix() + "enable WAL error: " + e);
101 | return false;
102 | }
103 | return true;
104 | }
105 |
106 | String getThreadLogTag() {
107 | Thread thread = Thread.currentThread();
108 |
109 | return "" + id + "," + thread.getName() + "(" + thread.getId() + ")";
110 | }
111 |
112 | String getThreadLogPrefix() {
113 | return "[" + getThreadLogTag() + "] ";
114 | }
115 |
116 |
117 | static void deleteDatabase(String path) {
118 | File file = new File(path);
119 |
120 | file.delete();
121 | new File(file.getPath() + "-journal").delete();
122 | new File(file.getPath() + "-shm").delete();
123 | new File(file.getPath() + "-wal").delete();
124 | }
125 | }
126 |
--------------------------------------------------------------------------------
/sqflite/android/src/main/java/com/davidmartos96/sqflite_sqlcipher/LogLevel.java:
--------------------------------------------------------------------------------
1 | package com.davidmartos96.sqflite_sqlcipher;
2 |
3 | import io.flutter.plugin.common.MethodCall;
4 |
5 | import static com.davidmartos96.sqflite_sqlcipher.Constant.PARAM_LOG_LEVEL;
6 |
7 | public class LogLevel {
8 |
9 | static final int none = 0;
10 | static final int sql = 1;
11 | static final int verbose = 2;
12 |
13 | static Integer getLogLevel(MethodCall methodCall) {
14 | return methodCall.argument(PARAM_LOG_LEVEL);
15 | }
16 |
17 | static boolean hasSqlLevel(int level) {
18 | return level >= sql;
19 | }
20 |
21 | static boolean hasVerboseLevel(int level) {
22 | return level >= verbose;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/sqflite/android/src/main/java/com/davidmartos96/sqflite_sqlcipher/SqlCommand.java:
--------------------------------------------------------------------------------
1 | package com.davidmartos96.sqflite_sqlcipher;
2 |
3 | import android.util.Log;
4 |
5 | import com.davidmartos96.sqflite_sqlcipher.dev.Debug;
6 |
7 | import java.util.ArrayList;
8 | import java.util.Arrays;
9 | import java.util.HashMap;
10 | import java.util.List;
11 | import java.util.Map;
12 |
13 | import static com.davidmartos96.sqflite_sqlcipher.Constant.TAG;
14 |
15 | public class SqlCommand {
16 | public String getSql() {
17 | return sql;
18 | }
19 |
20 | final private String sql;
21 | final private List