-
-
Notifications
You must be signed in to change notification settings - Fork 531
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[sqflite_darwin] wip allow concurrent usage using existing plugin
- Loading branch information
1 parent
3b30ef9
commit 5be9fca
Showing
12 changed files
with
89 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
export 'src/sqflite_darwin_plugin.dart' | ||
show initSqfliteDarwinPlugin, SqfliteDarwinPlugin; | ||
|
||
import 'sqflite_darwin_platform_interface.dart'; | ||
|
||
class SqfliteDarwin { | ||
Future<String?> getPlatformVersion() { | ||
return SqfliteDarwinPlatform.instance.getPlatformVersion(); | ||
} | ||
} | ||
// Compat | ||
export 'src/sqflite_darwin.dart' show SqfliteDarwin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import 'sqflite_darwin_platform_interface.dart'; | ||
|
||
class SqfliteDarwin { | ||
Future<String?> getPlatformVersion() { | ||
return SqfliteDarwinPlatform.instance.getPlatformVersion(); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
packages_flutter/sqflite_darwin/lib/src/sqflite_darwin_factory.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import 'package:sqflite_common/sqlite_api.dart'; | ||
|
||
import 'sqflite_import.dart'; | ||
|
||
final DatabaseFactory databaseFactorySqfliteDarwinPlugin = | ||
createDatabaseFactoryDarwinImpl(); | ||
|
||
/// Creates an FFI database factory | ||
DatabaseFactory createDatabaseFactoryDarwinImpl({String? tag = 'darwin'}) { | ||
return buildDatabaseFactory( | ||
tag: tag, | ||
invokeMethod: (String method, [Object? arguments]) { | ||
throw UnimplementedError(); | ||
}); | ||
} |
8 changes: 4 additions & 4 deletions
8
...in/lib/sqflite_darwin_method_channel.dart → ...ib/src/sqflite_darwin_method_channel.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:flutter/services.dart'; | ||
|
||
import 'sqflite_darwin_platform_interface.dart'; | ||
|
||
const sqfliteDarwinMethodChannel = MethodChannel('sqflite_darwin'); | ||
|
||
/// An implementation of [SqfliteDarwinPlatform] that uses method channels. | ||
class MethodChannelSqfliteDarwin extends SqfliteDarwinPlatform { | ||
/// The method channel used to interact with the native platform. | ||
@visibleForTesting | ||
final methodChannel = const MethodChannel('sqflite_darwin'); | ||
@override | ||
Future<String?> getPlatformVersion() async { | ||
final version = await methodChannel.invokeMethod<String>('getPlatformVersion'); | ||
final version = await sqfliteDarwinMethodChannel | ||
.invokeMethod<String>('getPlatformVersion'); | ||
return version; | ||
} | ||
} |
File renamed without changes.
21 changes: 21 additions & 0 deletions
21
packages_flutter/sqflite_darwin/lib/src/sqflite_darwin_plugin.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import 'package:sqflite_darwin/src/sqflite_darwin_factory.dart'; | ||
|
||
import 'sqflite_darwin_method_channel.dart'; | ||
|
||
import 'package:sqflite_common/sqflite.dart'; | ||
|
||
/// sqflite Plugin registration. | ||
class SqfliteDarwinPlugin { | ||
/// Registers this plugin as the default database factory (if not already set). | ||
static void registerWith() { | ||
databaseFactoryOrNull ??= databaseFactorySqfliteDarwinPlugin; | ||
} | ||
} | ||
|
||
/// Invoke a native method | ||
Future<T> invokeMethod<T>(String method, [Object? arguments]) async => | ||
await sqfliteDarwinMethodChannel.invokeMethod<T>(method, arguments) as T; | ||
|
||
void initSqfliteDarwinPlugin() { | ||
databaseFactoryOrNull = databaseFactorySqfliteDarwinPlugin; | ||
} |
12 changes: 12 additions & 0 deletions
12
packages_flutter/sqflite_darwin/lib/src/sqflite_import.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// To be imported | ||
// ignore_for_file: deprecated_member_use | ||
export 'package:sqflite_common/src/arg_utils.dart' show argumentsToString; | ||
export 'package:sqflite_common/src/compat.dart' show SqfliteOptions; | ||
export 'package:sqflite_common/src/constant.dart' | ||
show methodOpenDatabase, methodOptions, sqliteErrorCode; | ||
export 'package:sqflite_common/src/dev_utils.dart' show devPrint, devWarning; | ||
export 'package:sqflite_common/src/exception.dart' | ||
show SqfliteDatabaseException; | ||
export 'package:sqflite_common/src/mixin/constant.dart' show methodOpenDatabase; | ||
export 'package:sqflite_common/src/mixin/factory.dart' | ||
show buildDatabaseFactory, SqfliteInvokeHandler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
packages_flutter/sqflite_darwin/test/sqflite_darwin_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import 'package:flutter/cupertino.dart'; | ||
import 'package:sqflite_darwin/sqflite_darwin.dart'; | ||
import 'package:sqflite_example/main.dart'; | ||
|
||
/// Use regular sqflite, overridng to use Darwin iOS and MacOS | ||
void main() { | ||
WidgetsFlutterBinding.ensureInitialized(); | ||
initSqfliteDarwinPlugin(); | ||
mainExampleApp(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters