| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |||
| 8 | 8 | ||
| 9 | 9 | ## [0.1.1] - 2018-11-23 | |
| 10 | 10 | ### Added | |
| 11 | + - `SQLiteDatabase#beginTransaction()` method | ||
| 12 | + - `SQLiteDatabase#beginTransactionNonExclusive()` method | ||
| 13 | + - `SQLiteDatabase#endTransaction()` method | ||
| 11 | 14 | ||
| 12 | 15 | ## [0.1.0] - 2018-11-22 | |
| 13 | 16 | ### Added | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -100,6 +100,9 @@ Reference | |||
| 100 | 100 | - [`SQLiteDatabase.openOrCreateDatabase()`](https://pub.dartlang.org/documentation/flutter_sqlcipher/latest/sqlite/SQLiteDatabase/openOrCreateDatabase.html) | |
| 101 | 101 | - [`SQLiteDatabase#path`](https://pub.dartlang.org/documentation/flutter_sqlcipher/latest/sqlite/SQLiteDatabase/path.html) | |
| 102 | 102 | - [`SQLiteDatabase#version`](https://pub.dartlang.org/documentation/flutter_sqlcipher/latest/sqlite/SQLiteDatabase/version.html) | |
| 103 | + - [`SQLiteDatabase#beginTransaction()`](https://pub.dartlang.org/documentation/flutter_sqlcipher/latest/sqlite/SQLiteDatabase/beginTransaction.html) | ||
| 104 | + - [`SQLiteDatabase#beginTransactionNonExclusive()`](https://pub.dartlang.org/documentation/flutter_sqlcipher/latest/sqlite/SQLiteDatabase/beginTransactionNonExclusive.html) | ||
| 105 | + - [`SQLiteDatabase#endTransaction()`](https://pub.dartlang.org/documentation/flutter_sqlcipher/latest/sqlite/SQLiteDatabase/endTransaction.html) | ||
| 103 | 106 | - [`SQLiteDatabase#execSQL()`](https://pub.dartlang.org/documentation/flutter_sqlcipher/latest/sqlite/SQLiteDatabase/execSQL.html) | |
| 104 | 107 | - [`SQLiteDatabase#getPath()`](https://pub.dartlang.org/documentation/flutter_sqlcipher/latest/sqlite/SQLiteDatabase/getPath.html) | |
| 105 | 108 | - [`SQLiteDatabase#getVersion()`](https://pub.dartlang.org/documentation/flutter_sqlcipher/latest/sqlite/SQLiteDatabase/getVersion.html) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -56,6 +56,32 @@ class SQLiteDatabaseMethodHandler implements MethodCallHandler { | |||
| 56 | 56 | break; | |
| 57 | 57 | } | |
| 58 | 58 | ||
| 59 | + case "beginTransaction": { | ||
| 60 | + final SQLiteDatabase db = this.getDatabaseArgument(call); | ||
| 61 | + final String mode = getOptionalArgument(call, "mode", "exclusive"); | ||
| 62 | + switch (mode) { | ||
| 63 | + case "exclusive": | ||
| 64 | + db.beginTransaction(); | ||
| 65 | + break; | ||
| 66 | + case "immediate": | ||
| 67 | + //db.beginTransactionNonExclusive(); // TODO: this is missing in SQLCipher 3.5.9 | ||
| 68 | + db.beginTransaction(); | ||
| 69 | + break; | ||
| 70 | + default: | ||
| 71 | + assert(false); // unreachable | ||
| 72 | + throw new AssertionError(); | ||
| 73 | + } | ||
| 74 | + result.success(null); | ||
| 75 | + break; | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + case "endTransaction": { | ||
| 79 | + final SQLiteDatabase db = this.getDatabaseArgument(call); | ||
| 80 | + db.endTransaction(); | ||
| 81 | + result.success(null); | ||
| 82 | + break; | ||
| 83 | + } | ||
| 84 | + | ||
| 59 | 85 | case "execSQL": { | |
| 60 | 86 | final SQLiteDatabase db = this.getDatabaseArgument(call); | |
| 61 | 87 | final String sql = getRequiredArgument(call, "sql"); | |
@@ -90,7 +116,7 @@ class SQLiteDatabaseMethodHandler implements MethodCallHandler { | |||
| 90 | 116 | ||
| 91 | 117 | case "isWriteAheadLoggingEnabled": { | |
| 92 | 118 | final SQLiteDatabase db = this.getDatabaseArgument(call); | |
| 93 | - //result.success(db.isWriteAheadLoggingEnabled()); // TODO: this is missing in SQLCipher | ||
| 119 | + //result.success(db.isWriteAheadLoggingEnabled()); // TODO: this is missing in SQLCipher 3.5.9 | ||
| 94 | 120 | result.success(false); | |
| 95 | 121 | break; | |
| 96 | 122 | } | |
@@ -197,9 +223,16 @@ class SQLiteDatabaseMethodHandler implements MethodCallHandler { | |||
| 197 | 223 | private static <T> T | |
| 198 | 224 | getOptionalArgument(final MethodCall call, | |
| 199 | 225 | final String name) { | |
| 226 | + return getOptionalArgument(call, name, (T)null); | ||
| 227 | + } | ||
| 228 | + | ||
| 229 | + private static <T> T | ||
| 230 | + getOptionalArgument(final MethodCall call, | ||
| 231 | + final String name, | ||
| 232 | + final T defaultValue) { | ||
| 200 | 233 | assert(call != null); | |
| 201 | 234 | assert(name != null); | |
| 202 | 235 | ||
| 203 | - return call.hasArgument(name) ? (T)call.argument(name) : (T)null; | ||
| 236 | + return call.hasArgument(name) ? (T)call.argument(name) : defaultValue; | ||
| 204 | 237 | } | |
| 205 | 238 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -126,6 +126,30 @@ abstract class SQLiteDatabase { | |||
| 126 | 126 | /// This is simply a Dart-idiomatic getter alias for [getVersion()]. | |
| 127 | 127 | Future<int> get version => getVersion(); | |
| 128 | 128 | ||
| 129 | + /// Begins a transaction in `EXCLUSIVE` mode. | ||
| 130 | + /// | ||
| 131 | + /// See: https://developer.android.com/reference/android/database/sqlite/SQLiteDatabase#beginTransaction() | ||
| 132 | + Future<void> beginTransaction() { | ||
| 133 | + final Map<String, dynamic> request = <String, dynamic>{'id': id, 'mode': 'exclusive'}; | ||
| 134 | + return _channel.invokeMethod('beginTransaction', request); | ||
| 135 | + } | ||
| 136 | + | ||
| 137 | + /// Begins a transaction in `IMMEDIATE` mode. | ||
| 138 | + /// | ||
| 139 | + /// See: https://developer.android.com/reference/android/database/sqlite/SQLiteDatabase#beginTransactionNonExclusive() | ||
| 140 | + Future<void> beginTransactionNonExclusive() { | ||
| 141 | + final Map<String, dynamic> request = <String, dynamic>{'id': id, 'mode': 'immediate'}; | ||
| 142 | + return _channel.invokeMethod('beginTransaction', request); | ||
| 143 | + } | ||
| 144 | + | ||
| 145 | + /// Ends a transaction. | ||
| 146 | + /// | ||
| 147 | + /// See: https://developer.android.com/reference/android/database/sqlite/SQLiteDatabase#endTransaction() | ||
| 148 | + Future<void> endTransaction() { | ||
| 149 | + final Map<String, dynamic> request = <String, dynamic>{'id': id}; | ||
| 150 | + return _channel.invokeMethod('endTransaction', request); | ||
| 151 | + } | ||
| 152 | + | ||
| 129 | 153 | /// Executes a single SQL statement that is *not* a `SELECT` or any other SQL | |
| 130 | 154 | /// statement that returns data. | |
| 131 | 155 | /// | |
| Back | FazBrowse Home | New Git URL |
0 commit comments