diff --git a/packages_flutter/sqflite_darwin/.gitignore b/packages_flutter/sqflite_darwin/.gitignore new file mode 100644 index 00000000..64b12d81 --- /dev/null +++ b/packages_flutter/sqflite_darwin/.gitignore @@ -0,0 +1,30 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. +/pubspec.lock +**/doc/api/ +.dart_tool/ +build/ +/.metadata diff --git a/packages_flutter/sqflite_darwin/CHANGELOG.md b/packages_flutter/sqflite_darwin/CHANGELOG.md new file mode 100644 index 00000000..41cc7d81 --- /dev/null +++ b/packages_flutter/sqflite_darwin/CHANGELOG.md @@ -0,0 +1,3 @@ +## 0.0.1 + +* TODO: Describe initial release. diff --git a/packages_flutter/sqflite_darwin/LICENSE b/packages_flutter/sqflite_darwin/LICENSE new file mode 100644 index 00000000..8b0ee97e --- /dev/null +++ b/packages_flutter/sqflite_darwin/LICENSE @@ -0,0 +1,25 @@ +BSD 2-Clause License + +Copyright (c) 2024, Alexandre Roux Tekartik +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/packages_flutter/sqflite_darwin/README.md b/packages_flutter/sqflite_darwin/README.md new file mode 100644 index 00000000..bd6f92d2 --- /dev/null +++ b/packages_flutter/sqflite_darwin/README.md @@ -0,0 +1,3 @@ +# sqflite_darwin + +SQFlite plugin for Flutter on macOS/iOS diff --git a/packages_flutter/sqflite_darwin/analysis_options.yaml b/packages_flutter/sqflite_darwin/analysis_options.yaml new file mode 100644 index 00000000..a5744c1c --- /dev/null +++ b/packages_flutter/sqflite_darwin/analysis_options.yaml @@ -0,0 +1,4 @@ +include: package:flutter_lints/flutter.yaml + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/packages_flutter/sqflite_darwin/darwin/.gitignore b/packages_flutter/sqflite_darwin/darwin/.gitignore new file mode 100644 index 00000000..0c885071 --- /dev/null +++ b/packages_flutter/sqflite_darwin/darwin/.gitignore @@ -0,0 +1,38 @@ +.idea/ +.vagrant/ +.sconsign.dblite +.svn/ + +.DS_Store +*.swp +profile + +DerivedData/ +build/ +GeneratedPluginRegistrant.h +GeneratedPluginRegistrant.m + +.generated/ + +*.pbxuser +*.mode1v3 +*.mode2v3 +*.perspectivev3 + +!default.pbxuser +!default.mode1v3 +!default.mode2v3 +!default.perspectivev3 + +xcuserdata + +*.moved-aside + +*.pyc +*sync/ +Icon? +.tags* + +/Flutter/Generated.xcconfig +/Flutter/ephemeral/ +/Flutter/flutter_export_environment.sh \ No newline at end of file diff --git a/packages_flutter/sqflite_darwin/darwin/Assets/.gitkeep b/packages_flutter/sqflite_darwin/darwin/Assets/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/packages_flutter/sqflite_darwin/darwin/Classes/SqfliteDarwinPlugin.swift b/packages_flutter/sqflite_darwin/darwin/Classes/SqfliteDarwinPlugin.swift new file mode 100644 index 00000000..5dd156d3 --- /dev/null +++ b/packages_flutter/sqflite_darwin/darwin/Classes/SqfliteDarwinPlugin.swift @@ -0,0 +1,33 @@ +#if os(iOS) + import Flutter + import UIKit +#elseif os(macOS) + import FlutterMacOS + import Cocoa +#endif + + +public class SqfliteDarwinPlugin: NSObject, FlutterPlugin { + public static func register(with registrar: FlutterPluginRegistrar) { +#if os(iOS) + let channel = FlutterMethodChannel(name: "sqflite_darwin", binaryMessenger: registrar.messenger()); +#elseif os (macOS) + let channel = FlutterMethodChannel(name: "sqflite_darwin", binaryMessenger: registrar.messenger); +#endif + let instance = SqfliteDarwinPlugin() + registrar.addMethodCallDelegate(instance, channel: channel) + } + + public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { + switch call.method { + case "getPlatformVersion": + #if os(iOS) + result("iOS " + UIDevice.current.systemVersion) + #elseif os (macOS) + result("macOS " + ProcessInfo.processInfo.operatingSystemVersionString) + #endif + default: + result(FlutterMethodNotImplemented) + } + } +} diff --git a/packages_flutter/sqflite_darwin/darwin/Resources/PrivacyInfo.xcprivacy b/packages_flutter/sqflite_darwin/darwin/Resources/PrivacyInfo.xcprivacy new file mode 100644 index 00000000..0eca193e --- /dev/null +++ b/packages_flutter/sqflite_darwin/darwin/Resources/PrivacyInfo.xcprivacy @@ -0,0 +1,14 @@ + + + + + NSPrivacyTrackingDomains + + NSPrivacyAccessedAPITypes + + NSPrivacyCollectedDataTypes + + NSPrivacyTracking + + + \ No newline at end of file diff --git a/packages_flutter/sqflite_darwin/darwin/sqflite_darwin.podspec b/packages_flutter/sqflite_darwin/darwin/sqflite_darwin.podspec new file mode 100644 index 00000000..b54f084d --- /dev/null +++ b/packages_flutter/sqflite_darwin/darwin/sqflite_darwin.podspec @@ -0,0 +1,24 @@ +# +# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. +# Run `pod lib lint sqflite_darwin.podspec` to validate before publishing. +# +Pod::Spec.new do |s| + s.name = 'sqflite_darwin' + s.version = '0.0.1' + s.summary = 'SQLite plugin.' + s.description = <<-DESC +Access SQLite database. + DESC + s.homepage = 'https://github.com/tekartik/sqflite' + s.license = { :file => '../LICENSE' } + s.author = { 'Tekartik' => 'alex@tekartik.com' } + s.source = { :path => '.' } + s.source_files = 'Classes/**/*' + s.ios.dependency 'Flutter' + s.osx.dependency 'FlutterMacOS' + s.ios.deployment_target = '12.0' + s.osx.deployment_target = '10.14' + s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' } + s.swift_version = '5.0' + s.resource_bundles = {'sqflite_darwin_privacy' => ['Resources/PrivacyInfo.xcprivacy']} +end diff --git a/packages_flutter/sqflite_darwin/example/.gitignore b/packages_flutter/sqflite_darwin/example/.gitignore new file mode 100644 index 00000000..a9a1f98a --- /dev/null +++ b/packages_flutter/sqflite_darwin/example/.gitignore @@ -0,0 +1,45 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.pub-cache/ +.pub/ +/build/ + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release +/ios/ +/macos/ diff --git a/packages_flutter/sqflite_darwin/example/README.md b/packages_flutter/sqflite_darwin/example/README.md new file mode 100644 index 00000000..62aca876 --- /dev/null +++ b/packages_flutter/sqflite_darwin/example/README.md @@ -0,0 +1,3 @@ +# sqflite_darwin_example + +Demonstrates how to use the sqflite_darwin plugin. diff --git a/packages_flutter/sqflite_darwin/example/analysis_options.yaml b/packages_flutter/sqflite_darwin/example/analysis_options.yaml new file mode 100644 index 00000000..0d290213 --- /dev/null +++ b/packages_flutter/sqflite_darwin/example/analysis_options.yaml @@ -0,0 +1,28 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at https://dart.dev/lints. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/packages_flutter/sqflite_darwin/example/integration_test/plugin_integration_test.dart b/packages_flutter/sqflite_darwin/example/integration_test/plugin_integration_test.dart new file mode 100644 index 00000000..e6e85cfe --- /dev/null +++ b/packages_flutter/sqflite_darwin/example/integration_test/plugin_integration_test.dart @@ -0,0 +1,25 @@ +// This is a basic Flutter integration test. +// +// Since integration tests run in a full Flutter application, they can interact +// with the host side of a plugin implementation, unlike Dart unit tests. +// +// For more information about Flutter integration tests, please see +// https://docs.flutter.dev/cookbook/testing/integration/introduction + + +import 'package:flutter_test/flutter_test.dart'; +import 'package:integration_test/integration_test.dart'; + +import 'package:sqflite_darwin/sqflite_darwin.dart'; + +void main() { + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + + testWidgets('getPlatformVersion test', (WidgetTester tester) async { + final SqfliteDarwin plugin = SqfliteDarwin(); + final String? version = await plugin.getPlatformVersion(); + // The version string depends on the host platform running the test, so + // just assert that some non-empty string is returned. + expect(version?.isNotEmpty, true); + }); +} diff --git a/packages_flutter/sqflite_darwin/example/lib/main.dart b/packages_flutter/sqflite_darwin/example/lib/main.dart new file mode 100644 index 00000000..23e5c709 --- /dev/null +++ b/packages_flutter/sqflite_darwin/example/lib/main.dart @@ -0,0 +1,63 @@ +import 'package:flutter/material.dart'; +import 'dart:async'; + +import 'package:flutter/services.dart'; +import 'package:sqflite_darwin/sqflite_darwin.dart'; + +void main() { + runApp(const MyApp()); +} + +class MyApp extends StatefulWidget { + const MyApp({super.key}); + + @override + State createState() => _MyAppState(); +} + +class _MyAppState extends State { + String _platformVersion = 'Unknown'; + final _sqfliteDarwinPlugin = SqfliteDarwin(); + + @override + void initState() { + super.initState(); + initPlatformState(); + } + + // Platform messages are asynchronous, so we initialize in an async method. + Future initPlatformState() async { + String platformVersion; + // Platform messages may fail, so we use a try/catch PlatformException. + // We also handle the message potentially returning null. + try { + platformVersion = + await _sqfliteDarwinPlugin.getPlatformVersion() ?? 'Unknown platform version'; + } on PlatformException { + platformVersion = 'Failed to get platform version.'; + } + + // If the widget was removed from the tree while the asynchronous platform + // message was in flight, we want to discard the reply rather than calling + // setState to update our non-existent appearance. + if (!mounted) return; + + setState(() { + _platformVersion = platformVersion; + }); + } + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('Plugin example app'), + ), + body: Center( + child: Text('Running on: $_platformVersion\n'), + ), + ), + ); + } +} diff --git a/packages_flutter/sqflite_darwin/example/pubspec.yaml b/packages_flutter/sqflite_darwin/example/pubspec.yaml new file mode 100644 index 00000000..4ec67339 --- /dev/null +++ b/packages_flutter/sqflite_darwin/example/pubspec.yaml @@ -0,0 +1,85 @@ +name: sqflite_darwin_example +description: "Demonstrates how to use the sqflite_darwin plugin." +# The following line prevents the package from being accidentally published to +# pub.dev using `flutter pub publish`. This is preferred for private packages. +publish_to: 'none' # Remove this line if you wish to publish to pub.dev + +environment: + sdk: '>=3.2.5 <4.0.0' + +# Dependencies specify other packages that your package needs in order to work. +# To automatically upgrade your package dependencies to the latest versions +# consider running `flutter pub upgrade --major-versions`. Alternatively, +# dependencies can be manually updated by changing the version numbers below to +# the latest version available on pub.dev. To see which dependencies have newer +# versions available, run `flutter pub outdated`. +dependencies: + flutter: + sdk: flutter + + sqflite_darwin: + # When depending on this package from a real application you should use: + # sqflite_darwin: ^x.y.z + # See https://dart.dev/tools/pub/dependencies#version-constraints + # The example app is bundled with the plugin so we use a path dependency on + # the parent directory to use the current plugin's version. + path: ../ + + # The following adds the Cupertino Icons font to your application. + # Use with the CupertinoIcons class for iOS style icons. + cupertino_icons: ^1.0.2 + +dev_dependencies: + integration_test: + sdk: flutter + flutter_test: + sdk: flutter + + # The "flutter_lints" package below contains a set of recommended lints to + # encourage good coding practices. The lint set provided by the package is + # activated in the `analysis_options.yaml` file located at the root of your + # package. See that file for information about deactivating specific lint + # rules and activating additional ones. + flutter_lints: ^2.0.0 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter packages. +flutter: + + # The following line ensures that the Material Icons font is + # included with your application, so that you can use the icons in + # the material Icons class. + uses-material-design: true + + # To add assets to your application, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware + + # For details regarding adding assets from package dependencies, see + # https://flutter.dev/assets-and-images/#from-packages + + # To add custom fonts to your application, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts from package dependencies, + # see https://flutter.dev/custom-fonts/#from-packages diff --git a/packages_flutter/sqflite_darwin/example/test/widget_test.dart b/packages_flutter/sqflite_darwin/example/test/widget_test.dart new file mode 100644 index 00000000..03216120 --- /dev/null +++ b/packages_flutter/sqflite_darwin/example/test/widget_test.dart @@ -0,0 +1,27 @@ +// This is a basic Flutter widget test. +// +// To perform an interaction with a widget in your test, use the WidgetTester +// utility in the flutter_test package. For example, you can send tap and scroll +// gestures. You can also use WidgetTester to find child widgets in the widget +// tree, read text, and verify that the values of widget properties are correct. + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import 'package:sqflite_darwin_example/main.dart'; + +void main() { + testWidgets('Verify Platform version', (WidgetTester tester) async { + // Build our app and trigger a frame. + await tester.pumpWidget(const MyApp()); + + // Verify that platform version is retrieved. + expect( + find.byWidgetPredicate( + (Widget widget) => widget is Text && + widget.data!.startsWith('Running on:'), + ), + findsOneWidget, + ); + }); +} diff --git a/packages_flutter/sqflite_darwin/lib/sqflite_darwin.dart b/packages_flutter/sqflite_darwin/lib/sqflite_darwin.dart new file mode 100644 index 00000000..18fa4f7c --- /dev/null +++ b/packages_flutter/sqflite_darwin/lib/sqflite_darwin.dart @@ -0,0 +1,8 @@ + +import 'sqflite_darwin_platform_interface.dart'; + +class SqfliteDarwin { + Future getPlatformVersion() { + return SqfliteDarwinPlatform.instance.getPlatformVersion(); + } +} diff --git a/packages_flutter/sqflite_darwin/lib/sqflite_darwin_method_channel.dart b/packages_flutter/sqflite_darwin/lib/sqflite_darwin_method_channel.dart new file mode 100644 index 00000000..0b8f76d8 --- /dev/null +++ b/packages_flutter/sqflite_darwin/lib/sqflite_darwin_method_channel.dart @@ -0,0 +1,17 @@ +import 'package:flutter/foundation.dart'; +import 'package:flutter/services.dart'; + +import 'sqflite_darwin_platform_interface.dart'; + +/// 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 getPlatformVersion() async { + final version = await methodChannel.invokeMethod('getPlatformVersion'); + return version; + } +} diff --git a/packages_flutter/sqflite_darwin/lib/sqflite_darwin_platform_interface.dart b/packages_flutter/sqflite_darwin/lib/sqflite_darwin_platform_interface.dart new file mode 100644 index 00000000..c42d576d --- /dev/null +++ b/packages_flutter/sqflite_darwin/lib/sqflite_darwin_platform_interface.dart @@ -0,0 +1,29 @@ +import 'package:plugin_platform_interface/plugin_platform_interface.dart'; + +import 'sqflite_darwin_method_channel.dart'; + +abstract class SqfliteDarwinPlatform extends PlatformInterface { + /// Constructs a SqfliteDarwinPlatform. + SqfliteDarwinPlatform() : super(token: _token); + + static final Object _token = Object(); + + static SqfliteDarwinPlatform _instance = MethodChannelSqfliteDarwin(); + + /// The default instance of [SqfliteDarwinPlatform] to use. + /// + /// Defaults to [MethodChannelSqfliteDarwin]. + static SqfliteDarwinPlatform get instance => _instance; + + /// Platform-specific implementations should set this with their own + /// platform-specific class that extends [SqfliteDarwinPlatform] when + /// they register themselves. + static set instance(SqfliteDarwinPlatform instance) { + PlatformInterface.verifyToken(instance, _token); + _instance = instance; + } + + Future getPlatformVersion() { + throw UnimplementedError('platformVersion() has not been implemented.'); + } +} diff --git a/packages_flutter/sqflite_darwin/pubspec.yaml b/packages_flutter/sqflite_darwin/pubspec.yaml new file mode 100644 index 00000000..e40a9707 --- /dev/null +++ b/packages_flutter/sqflite_darwin/pubspec.yaml @@ -0,0 +1,73 @@ +name: sqflite_darwin +description: "A new Flutter plugin project." +version: 0.0.1 +homepage: + +environment: + sdk: '>=3.2.5 <4.0.0' + flutter: '>=3.3.0' + +dependencies: + flutter: + sdk: flutter + plugin_platform_interface: ^2.0.2 + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^2.0.0 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter packages. +flutter: + # This section identifies this Flutter project as a plugin project. + # The 'pluginClass' specifies the class (in Java, Kotlin, Swift, Objective-C, etc.) + # which should be registered in the plugin registry. This is required for + # using method channels. + # The Android 'package' specifies package in which the registered class is. + # This is required for using method channels on Android. + # The 'ffiPlugin' specifies that native code should be built and bundled. + # This is required for using `dart:ffi`. + # All these are used by the tooling to maintain consistency when + # adding or updating assets for this project. + plugin: + platforms: + ios: + pluginClass: SqfliteDarwinPlugin + sharedDarwinSource: true + macos: + pluginClass: SqfliteDarwinPlugin + sharedDarwinSource: true + + # To add assets to your plugin package, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + # + # For details regarding assets in packages, see + # https://flutter.dev/assets-and-images/#from-packages + # + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware + + # To add custom fonts to your plugin package, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts in packages, see + # https://flutter.dev/custom-fonts/#from-packages diff --git a/packages_flutter/sqflite_darwin/test/sqflite_darwin_method_channel_test.dart b/packages_flutter/sqflite_darwin/test/sqflite_darwin_method_channel_test.dart new file mode 100644 index 00000000..b6929c02 --- /dev/null +++ b/packages_flutter/sqflite_darwin/test/sqflite_darwin_method_channel_test.dart @@ -0,0 +1,27 @@ +import 'package:flutter/services.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:sqflite_darwin/sqflite_darwin_method_channel.dart'; + +void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + + MethodChannelSqfliteDarwin platform = MethodChannelSqfliteDarwin(); + const MethodChannel channel = MethodChannel('sqflite_darwin'); + + setUp(() { + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler( + channel, + (MethodCall methodCall) async { + return '42'; + }, + ); + }); + + tearDown(() { + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(channel, null); + }); + + test('getPlatformVersion', () async { + expect(await platform.getPlatformVersion(), '42'); + }); +} diff --git a/packages_flutter/sqflite_darwin/test/sqflite_darwin_test.dart b/packages_flutter/sqflite_darwin/test/sqflite_darwin_test.dart new file mode 100644 index 00000000..a85fb43f --- /dev/null +++ b/packages_flutter/sqflite_darwin/test/sqflite_darwin_test.dart @@ -0,0 +1,29 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:sqflite_darwin/sqflite_darwin.dart'; +import 'package:sqflite_darwin/sqflite_darwin_platform_interface.dart'; +import 'package:sqflite_darwin/sqflite_darwin_method_channel.dart'; +import 'package:plugin_platform_interface/plugin_platform_interface.dart'; + +class MockSqfliteDarwinPlatform + with MockPlatformInterfaceMixin + implements SqfliteDarwinPlatform { + + @override + Future getPlatformVersion() => Future.value('42'); +} + +void main() { + final SqfliteDarwinPlatform initialPlatform = SqfliteDarwinPlatform.instance; + + test('$MethodChannelSqfliteDarwin is the default instance', () { + expect(initialPlatform, isInstanceOf()); + }); + + test('getPlatformVersion', () async { + SqfliteDarwin sqfliteDarwinPlugin = SqfliteDarwin(); + MockSqfliteDarwinPlatform fakePlatform = MockSqfliteDarwinPlatform(); + SqfliteDarwinPlatform.instance = fakePlatform; + + expect(await sqfliteDarwinPlugin.getPlatformVersion(), '42'); + }); +} diff --git a/sqflite/ios/sqflite.podspec b/sqflite/ios/sqflite.podspec index 27b66938..e976c8fe 100644 --- a/sqflite/ios/sqflite.podspec +++ b/sqflite/ios/sqflite.podspec @@ -6,7 +6,7 @@ Pod::Spec.new do |s| s.version = '0.0.3' s.summary = 'SQLite plugin.' s.description = <<-DESC -Accss SQLite database. +Access SQLite database. DESC s.homepage = 'https://github.com/tekartik/sqflite' s.license = { :file => '../LICENSE' } diff --git a/sqflite/macos/sqflite.podspec b/sqflite/macos/sqflite.podspec index a7867724..018e85ea 100644 --- a/sqflite/macos/sqflite.podspec +++ b/sqflite/macos/sqflite.podspec @@ -17,7 +17,7 @@ Accss SQLite database. s.dependency 'FlutterMacOS' s.dependency 'FMDB', '>= 2.7.5' - s.platform = :osx, '10.11' + s.platform = :osx, '10.14' s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' } s.swift_version = '5.0' s.resource_bundles = {'sqflite_macos_privacy' => ['Resources/PrivacyInfo.xcprivacy']}