diff --git a/splitio/example/pubspec.lock b/splitio/example/pubspec.lock index 1de670f..a216ab7 100644 --- a/splitio/example/pubspec.lock +++ b/splitio/example/pubspec.lock @@ -134,7 +134,14 @@ packages: path: ".." relative: true source: path - version: "0.1.1" + version: "0.1.2" + splitio_android: + dependency: transitive + description: + path: "../../splitio_android" + relative: true + source: path + version: "0.1.2" splitio_platform_interface: dependency: transitive description: diff --git a/splitio/example/pubspec.yaml b/splitio/example/pubspec.yaml index 35cec97..49d15a3 100644 --- a/splitio/example/pubspec.yaml +++ b/splitio/example/pubspec.yaml @@ -8,12 +8,6 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev environment: sdk: ">=2.16.2 <3.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 @@ -25,60 +19,12 @@ dependencies: # 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: 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: ^1.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. 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/splitio/pubspec.yaml b/splitio/pubspec.yaml index ddc7878..87f2500 100644 --- a/splitio/pubspec.yaml +++ b/splitio/pubspec.yaml @@ -1,6 +1,6 @@ name: splitio description: Official plugin for split.io, the platform for controlled rollouts, which serves features to your users via a Split feature flag to manage your complete customer experience. -version: 0.1.1 +version: 0.1.2 homepage: https://split.io/ repository: https://github.com/splitio/flutter-sdk-plugin/splitio/ @@ -8,22 +8,23 @@ environment: sdk: ">=2.16.2 <3.0.0" flutter: ">=2.5.0" +flutter: + plugin: + platforms: + android: + default_package: splitio_android + ios: + pluginClass: SplitioPlugin + dependencies: flutter: sdk: flutter splitio_platform_interface: # ^1.0.0 path: ../splitio_platform_interface + splitio_android: # ^1.0.0 + path: ../splitio_android dev_dependencies: flutter_test: sdk: flutter flutter_lints: ^1.0.0 - -flutter: - plugin: - platforms: - android: - package: io.split.splitio - pluginClass: SplitioPlugin - ios: - pluginClass: SplitioPlugin diff --git a/splitio_android/.gitignore b/splitio_android/.gitignore new file mode 100644 index 0000000..9be145f --- /dev/null +++ b/splitio_android/.gitignore @@ -0,0 +1,29 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ + +# 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/ +.packages +build/ diff --git a/splitio_android/CHANGELOG.md b/splitio_android/CHANGELOG.md new file mode 100644 index 0000000..cd0d685 --- /dev/null +++ b/splitio_android/CHANGELOG.md @@ -0,0 +1,3 @@ +# 0.1.2 + +Splits from `splitio` as federated implementation. diff --git a/splitio_android/LICENSE b/splitio_android/LICENSE new file mode 100644 index 0000000..20e4bd8 --- /dev/null +++ b/splitio_android/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + https://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/splitio_android/README.md b/splitio_android/README.md new file mode 100644 index 0000000..54614af --- /dev/null +++ b/splitio_android/README.md @@ -0,0 +1,11 @@ +# splitio\_android + +The Android implementation of [`splitio`][1]. + +## Usage + +This package is [endorsed][2], which means you can simply use `splitio` +normally. This package will be automatically included in your app when you do. + +[1]: https://pub.dev/packages/splitio +[2]: https://flutter.dev/docs/development/packages-and-plugins/developing-packages#endorsed-federated-plugin diff --git a/splitio_android/analysis_options.yaml b/splitio_android/analysis_options.yaml new file mode 100644 index 0000000..a5744c1 --- /dev/null +++ b/splitio_android/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/splitio/android/.gitignore b/splitio_android/android/.gitignore similarity index 100% rename from splitio/android/.gitignore rename to splitio_android/android/.gitignore diff --git a/splitio/android/build.gradle b/splitio_android/android/build.gradle similarity index 100% rename from splitio/android/build.gradle rename to splitio_android/android/build.gradle diff --git a/splitio/android/settings.gradle b/splitio_android/android/settings.gradle similarity index 100% rename from splitio/android/settings.gradle rename to splitio_android/android/settings.gradle diff --git a/splitio/android/src/main/AndroidManifest.xml b/splitio_android/android/src/main/AndroidManifest.xml similarity index 100% rename from splitio/android/src/main/AndroidManifest.xml rename to splitio_android/android/src/main/AndroidManifest.xml diff --git a/splitio/android/src/main/java/io/split/splitio/ArgumentParser.java b/splitio_android/android/src/main/java/io/split/splitio/ArgumentParser.java similarity index 100% rename from splitio/android/src/main/java/io/split/splitio/ArgumentParser.java rename to splitio_android/android/src/main/java/io/split/splitio/ArgumentParser.java diff --git a/splitio/android/src/main/java/io/split/splitio/ArgumentParserImpl.java b/splitio_android/android/src/main/java/io/split/splitio/ArgumentParserImpl.java similarity index 100% rename from splitio/android/src/main/java/io/split/splitio/ArgumentParserImpl.java rename to splitio_android/android/src/main/java/io/split/splitio/ArgumentParserImpl.java diff --git a/splitio/android/src/main/java/io/split/splitio/AttributesWrapper.java b/splitio_android/android/src/main/java/io/split/splitio/AttributesWrapper.java similarity index 100% rename from splitio/android/src/main/java/io/split/splitio/AttributesWrapper.java rename to splitio_android/android/src/main/java/io/split/splitio/AttributesWrapper.java diff --git a/splitio/android/src/main/java/io/split/splitio/Constants.java b/splitio_android/android/src/main/java/io/split/splitio/Constants.java similarity index 100% rename from splitio/android/src/main/java/io/split/splitio/Constants.java rename to splitio_android/android/src/main/java/io/split/splitio/Constants.java diff --git a/splitio/android/src/main/java/io/split/splitio/EvaluationWrapper.java b/splitio_android/android/src/main/java/io/split/splitio/EvaluationWrapper.java similarity index 100% rename from splitio/android/src/main/java/io/split/splitio/EvaluationWrapper.java rename to splitio_android/android/src/main/java/io/split/splitio/EvaluationWrapper.java diff --git a/splitio/android/src/main/java/io/split/splitio/Helper.java b/splitio_android/android/src/main/java/io/split/splitio/Helper.java similarity index 100% rename from splitio/android/src/main/java/io/split/splitio/Helper.java rename to splitio_android/android/src/main/java/io/split/splitio/Helper.java diff --git a/splitio/android/src/main/java/io/split/splitio/ImpressionListenerImp.java b/splitio_android/android/src/main/java/io/split/splitio/ImpressionListenerImp.java similarity index 100% rename from splitio/android/src/main/java/io/split/splitio/ImpressionListenerImp.java rename to splitio_android/android/src/main/java/io/split/splitio/ImpressionListenerImp.java diff --git a/splitio/android/src/main/java/io/split/splitio/SplitClientConfigHelper.java b/splitio_android/android/src/main/java/io/split/splitio/SplitClientConfigHelper.java similarity index 100% rename from splitio/android/src/main/java/io/split/splitio/SplitClientConfigHelper.java rename to splitio_android/android/src/main/java/io/split/splitio/SplitClientConfigHelper.java diff --git a/splitio/android/src/main/java/io/split/splitio/SplitFactoryProvider.java b/splitio_android/android/src/main/java/io/split/splitio/SplitFactoryProvider.java similarity index 100% rename from splitio/android/src/main/java/io/split/splitio/SplitFactoryProvider.java rename to splitio_android/android/src/main/java/io/split/splitio/SplitFactoryProvider.java diff --git a/splitio/android/src/main/java/io/split/splitio/SplitFactoryProviderImpl.java b/splitio_android/android/src/main/java/io/split/splitio/SplitFactoryProviderImpl.java similarity index 100% rename from splitio/android/src/main/java/io/split/splitio/SplitFactoryProviderImpl.java rename to splitio_android/android/src/main/java/io/split/splitio/SplitFactoryProviderImpl.java diff --git a/splitio/android/src/main/java/io/split/splitio/SplitMethodParser.java b/splitio_android/android/src/main/java/io/split/splitio/SplitMethodParser.java similarity index 100% rename from splitio/android/src/main/java/io/split/splitio/SplitMethodParser.java rename to splitio_android/android/src/main/java/io/split/splitio/SplitMethodParser.java diff --git a/splitio/android/src/main/java/io/split/splitio/SplitMethodParserImpl.java b/splitio_android/android/src/main/java/io/split/splitio/SplitMethodParserImpl.java similarity index 100% rename from splitio/android/src/main/java/io/split/splitio/SplitMethodParserImpl.java rename to splitio_android/android/src/main/java/io/split/splitio/SplitMethodParserImpl.java diff --git a/splitio/android/src/main/java/io/split/splitio/SplitProviderHelper.java b/splitio_android/android/src/main/java/io/split/splitio/SplitProviderHelper.java similarity index 100% rename from splitio/android/src/main/java/io/split/splitio/SplitProviderHelper.java rename to splitio_android/android/src/main/java/io/split/splitio/SplitProviderHelper.java diff --git a/splitio/android/src/main/java/io/split/splitio/SplitWrapper.java b/splitio_android/android/src/main/java/io/split/splitio/SplitWrapper.java similarity index 100% rename from splitio/android/src/main/java/io/split/splitio/SplitWrapper.java rename to splitio_android/android/src/main/java/io/split/splitio/SplitWrapper.java diff --git a/splitio/android/src/main/java/io/split/splitio/SplitWrapperImpl.java b/splitio_android/android/src/main/java/io/split/splitio/SplitWrapperImpl.java similarity index 100% rename from splitio/android/src/main/java/io/split/splitio/SplitWrapperImpl.java rename to splitio_android/android/src/main/java/io/split/splitio/SplitWrapperImpl.java diff --git a/splitio/android/src/main/java/io/split/splitio/SplitioPlugin.java b/splitio_android/android/src/main/java/io/split/splitio/SplitioPlugin.java similarity index 97% rename from splitio/android/src/main/java/io/split/splitio/SplitioPlugin.java rename to splitio_android/android/src/main/java/io/split/splitio/SplitioPlugin.java index a2645d0..6cc5c2c 100644 --- a/splitio/android/src/main/java/io/split/splitio/SplitioPlugin.java +++ b/splitio_android/android/src/main/java/io/split/splitio/SplitioPlugin.java @@ -23,7 +23,7 @@ public class SplitioPlugin implements FlutterPlugin, MethodCallHandler { @Override public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBinding) { - channel = new MethodChannel(flutterPluginBinding.getBinaryMessenger(), "splitio"); + channel = new MethodChannel(flutterPluginBinding.getBinaryMessenger(), "splitio.io/splitio_android"); channel.setMethodCallHandler(this); SplitFactoryProvider provider = getSplitFactoryProvider(flutterPluginBinding.getApplicationContext()); methodParser = new SplitMethodParserImpl(flutterPluginBinding.getApplicationContext(), channel, provider); diff --git a/splitio/android/src/test/java/io/split/splitio/ArgumentParserImplTest.java b/splitio_android/android/src/test/java/io/split/splitio/ArgumentParserImplTest.java similarity index 100% rename from splitio/android/src/test/java/io/split/splitio/ArgumentParserImplTest.java rename to splitio_android/android/src/test/java/io/split/splitio/ArgumentParserImplTest.java diff --git a/splitio/android/src/test/java/io/split/splitio/ImpressionListenerImpTest.java b/splitio_android/android/src/test/java/io/split/splitio/ImpressionListenerImpTest.java similarity index 100% rename from splitio/android/src/test/java/io/split/splitio/ImpressionListenerImpTest.java rename to splitio_android/android/src/test/java/io/split/splitio/ImpressionListenerImpTest.java diff --git a/splitio/android/src/test/java/io/split/splitio/SplitClientConfigHelperTest.java b/splitio_android/android/src/test/java/io/split/splitio/SplitClientConfigHelperTest.java similarity index 100% rename from splitio/android/src/test/java/io/split/splitio/SplitClientConfigHelperTest.java rename to splitio_android/android/src/test/java/io/split/splitio/SplitClientConfigHelperTest.java diff --git a/splitio/android/src/test/java/io/split/splitio/SplitMethodParserImplTest.java b/splitio_android/android/src/test/java/io/split/splitio/SplitMethodParserImplTest.java similarity index 100% rename from splitio/android/src/test/java/io/split/splitio/SplitMethodParserImplTest.java rename to splitio_android/android/src/test/java/io/split/splitio/SplitMethodParserImplTest.java diff --git a/splitio/android/src/test/java/io/split/splitio/SplitProviderHelperImplTest.java b/splitio_android/android/src/test/java/io/split/splitio/SplitProviderHelperImplTest.java similarity index 100% rename from splitio/android/src/test/java/io/split/splitio/SplitProviderHelperImplTest.java rename to splitio_android/android/src/test/java/io/split/splitio/SplitProviderHelperImplTest.java diff --git a/splitio/android/src/test/java/io/split/splitio/SplitWrapperImplTest.java b/splitio_android/android/src/test/java/io/split/splitio/SplitWrapperImplTest.java similarity index 100% rename from splitio/android/src/test/java/io/split/splitio/SplitWrapperImplTest.java rename to splitio_android/android/src/test/java/io/split/splitio/SplitWrapperImplTest.java diff --git a/splitio_android/lib/splitio_android.dart b/splitio_android/lib/splitio_android.dart new file mode 100644 index 0000000..78cd29f --- /dev/null +++ b/splitio_android/lib/splitio_android.dart @@ -0,0 +1,16 @@ +import 'package:flutter/services.dart'; +import 'package:splitio_platform_interface/splitio_platform_interface.dart'; + +const MethodChannel _methodChannel = + MethodChannel('splitio.io/splitio_android'); + +/// Implementation for Android of [SplitioPlatform]. +class SplitioAndroid extends MethodChannelPlatform { + /// Registers this class as the default platform implementation. + static void registerWith() { + SplitioPlatform.instance = SplitioAndroid(); + } + + @override + MethodChannel get methodChannel => _methodChannel; +} diff --git a/splitio_android/pubspec.yaml b/splitio_android/pubspec.yaml new file mode 100644 index 0000000..366ef28 --- /dev/null +++ b/splitio_android/pubspec.yaml @@ -0,0 +1,29 @@ +name: splitio_android +description: The official Android implementation of splitio Flutter plugin. +repository: https://github.com/splitio/flutter-sdk-plugin/splitio/splitio_android +version: 0.1.2 +publish_to: 'none' + +environment: + sdk: ">=2.16.2 <3.0.0" + flutter: ">=2.5.0" + +flutter: + plugin: + implements: splitio + platforms: + android: + package: io.split.splitio + pluginClass: SplitioPlugin + dartPluginClass: SplitioAndroid + +dependencies: + flutter: + sdk: flutter + splitio_platform_interface: # ^1.0.0 + path: ../splitio_platform_interface + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^1.0.0 diff --git a/splitio_android/test/splitio_android_test.dart b/splitio_android/test/splitio_android_test.dart new file mode 100644 index 0000000..e33332e --- /dev/null +++ b/splitio_android/test/splitio_android_test.dart @@ -0,0 +1,515 @@ +import 'package:flutter/services.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:splitio_android/splitio_android.dart'; +import 'package:splitio_platform_interface/split_configuration.dart'; + +void main() { + const MethodChannel _channel = MethodChannel('splitio.io/splitio_android'); + + String methodName = ''; + dynamic methodArguments; + + TestWidgetsFlutterBinding.ensureInitialized(); + + SplitioAndroid _platform = SplitioAndroid(); + + void _simulateMethodInvocation(String methodName, + {String key = 'key', + String? bucketingKey, + Map? arguments}) { + arguments ??= {}; + arguments.addAll({'matchingKey': key, 'bucketingKey': bucketingKey}); + _channel.invokeMethod(methodName, arguments); + } + + setUp(() { + _channel.setMockMethodCallHandler((MethodCall methodCall) async { + methodName = methodCall.method; + methodArguments = methodCall.arguments; + + _platform.handle(methodCall); + switch (methodCall.method) { + case 'getTreatment': + return ''; + case 'getTreatments': + return {'split1': 'on', 'split2': 'off'}; + case 'getTreatmentsWithConfig': + return { + 'split1': {'treatment': 'on', 'config': null}, + 'split2': {'treatment': 'off', 'config': null} + }; + case 'track': + return true; + case 'getAttribute': + return true; + case 'getAllAttributes': + return { + 'attr_1': true, + 'attr_2': ['list-element'], + 'attr_3': 28.20 + }; + case 'setAttribute': + case 'setAttributes': + case 'removeAttribute': + case 'clearAttributes': + return true; + } + }); + }); + + group('evaluation', () { + test('getTreatment without attributes', () async { + _platform.getTreatment( + matchingKey: 'matching-key', + bucketingKey: 'bucketing-key', + splitName: 'split'); + + expect(methodName, 'getTreatment'); + expect(methodArguments, { + 'splitName': 'split', + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + 'attributes': {} + }); + }); + + test('getTreatment with attributes', () async { + _platform.getTreatment( + matchingKey: 'matching-key', + bucketingKey: 'bucketing-key', + splitName: 'split', + attributes: {'attr1': true}); + + expect(methodName, 'getTreatment'); + expect(methodArguments, { + 'splitName': 'split', + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + 'attributes': {'attr1': true} + }); + }); + + test('getTreatments without attributes', () async { + _platform.getTreatments( + matchingKey: 'matching-key', + bucketingKey: 'bucketing-key', + splitNames: ['split1', 'split2']); + + expect(methodName, 'getTreatments'); + expect(methodArguments, { + 'splitName': ['split1', 'split2'], + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + 'attributes': {} + }); + }); + + test('getTreatments with attributes', () async { + _platform.getTreatments( + matchingKey: 'matching-key', + bucketingKey: 'bucketing-key', + splitNames: ['split1', 'split2'], + attributes: {'attr1': true}); + + expect(methodName, 'getTreatments'); + expect(methodArguments, { + 'splitName': ['split1', 'split2'], + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + 'attributes': {'attr1': true} + }); + }); + + test('getTreatmentWithConfig with attributes', () async { + _platform.getTreatmentWithConfig( + matchingKey: 'matching-key', + bucketingKey: 'bucketing-key', + splitName: 'split1', + attributes: {'attr1': true}); + + expect(methodName, 'getTreatmentWithConfig'); + expect(methodArguments, { + 'splitName': 'split1', + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + 'attributes': {'attr1': true} + }); + }); + + test('getTreatmentWithConfig without attributes', () async { + _platform.getTreatmentWithConfig( + matchingKey: 'matching-key', + bucketingKey: 'bucketing-key', + splitName: 'split1'); + + expect(methodName, 'getTreatmentWithConfig'); + expect(methodArguments, { + 'splitName': 'split1', + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + 'attributes': {} + }); + }); + + test('getTreatmentsWithConfig without attributes', () async { + _platform.getTreatmentsWithConfig( + matchingKey: 'matching-key', + bucketingKey: 'bucketing-key', + splitNames: ['split1', 'split2']); + + expect(methodName, 'getTreatmentsWithConfig'); + expect(methodArguments, { + 'splitName': ['split1', 'split2'], + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + 'attributes': {} + }); + }); + + test('getTreatmentsWithConfig with attributes', () async { + _platform.getTreatmentsWithConfig( + matchingKey: 'matching-key', + bucketingKey: 'bucketing-key', + splitNames: ['split1', 'split2'], + attributes: {'attr1': true}); + + expect(methodName, 'getTreatmentsWithConfig'); + expect(methodArguments, { + 'splitName': ['split1', 'split2'], + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + 'attributes': {'attr1': true} + }); + }); + }); + + group('track', () { + test('track with traffic type & value', () async { + _platform.track( + matchingKey: 'matching-key', + bucketingKey: 'bucketing-key', + eventType: 'my_event', + trafficType: 'my_traffic_type', + value: 25.10); + expect(methodName, 'track'); + expect(methodArguments, { + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + 'eventType': 'my_event', + 'trafficType': 'my_traffic_type', + 'value': 25.10 + }); + }); + + test('track with value', () async { + _platform.track( + matchingKey: 'matching-key', + bucketingKey: 'bucketing-key', + eventType: 'my_event', + value: 25.10); + expect(methodName, 'track'); + expect(methodArguments, { + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + 'eventType': 'my_event', + 'value': 25.10 + }); + }); + + test('track with traffic type', () async { + _platform.track( + matchingKey: 'matching-key', + bucketingKey: 'bucketing-key', + eventType: 'my_event', + trafficType: 'my_traffic_type'); + expect(methodName, 'track'); + expect(methodArguments, { + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + 'eventType': 'my_event', + 'trafficType': 'my_traffic_type', + }); + }); + }); + + group('attributes', () { + test('get single attribute', () async { + _platform.getAttribute( + matchingKey: 'matching-key', + bucketingKey: 'bucketing-key', + attributeName: 'attribute-name'); + expect(methodName, 'getAttribute'); + expect(methodArguments, { + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + 'attributeName': 'attribute-name', + }); + }); + + test('get all attributes', () async { + _platform.getAllAttributes( + matchingKey: 'matching-key', bucketingKey: 'bucketing-key'); + expect(methodName, 'getAllAttributes'); + expect(methodArguments, { + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + }); + }); + + test('set attribute', () async { + _platform.setAttribute( + matchingKey: 'matching-key', + bucketingKey: 'bucketing-key', + attributeName: 'my_attr', + value: 'attr_value'); + expect(methodName, 'setAttribute'); + expect(methodArguments, { + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + 'attributeName': 'my_attr', + 'value': 'attr_value', + }); + }); + + test('set multiple attributes', () async { + _platform.setAttributes( + matchingKey: 'matching-key', + bucketingKey: 'bucketing-key', + attributes: { + 'bool_attr': true, + 'number_attr': 25.56, + 'string_attr': 'attr-value', + 'list_attr': ['one', 'two'], + }); + expect(methodName, 'setAttributes'); + expect(methodArguments, { + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + 'attributes': { + 'bool_attr': true, + 'number_attr': 25.56, + 'string_attr': 'attr-value', + 'list_attr': ['one', 'two'], + } + }); + }); + + test('remove attribute', () async { + _platform.removeAttribute( + matchingKey: 'matching-key', + bucketingKey: 'bucketing-key', + attributeName: 'attr-name'); + expect(methodName, 'removeAttribute'); + expect(methodArguments, { + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + 'attributeName': 'attr-name', + }); + }); + + test('clear attributes', () async { + _platform.clearAttributes( + matchingKey: 'matching-key', bucketingKey: 'bucketing-key'); + expect(methodName, 'clearAttributes'); + expect(methodArguments, { + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + }); + }); + + test('flush', () async { + _platform.flush( + matchingKey: 'matching-key', bucketingKey: 'bucketing-key'); + expect(methodName, 'flush'); + expect(methodArguments, { + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + }); + }); + + test('destroy', () async { + _platform.destroy( + matchingKey: 'matching-key', bucketingKey: 'bucketing-key'); + expect(methodName, 'destroy'); + expect(methodArguments, { + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + }); + }); + }); + + group('initialization', () { + test('init with matching key only', () { + _platform.init( + apiKey: 'api-key', matchingKey: 'matching-key', bucketingKey: null); + + expect(methodName, 'init'); + expect(methodArguments, { + 'apiKey': 'api-key', + 'matchingKey': 'matching-key', + 'sdkConfiguration': {} + }); + }); + + test('init with bucketing key', () { + _platform.init( + apiKey: 'api-key', + matchingKey: 'matching-key', + bucketingKey: 'bucketing-key'); + expect(methodName, 'init'); + expect(methodArguments, { + 'apiKey': 'api-key', + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + 'sdkConfiguration': {} + }); + }); + + test('init with config', () { + _platform.init( + apiKey: 'api-key', + matchingKey: 'matching-key', + bucketingKey: 'bucketing-key', + sdkConfiguration: + SplitConfiguration(enableDebug: true, streamingEnabled: false)); + expect(methodName, 'init'); + expect(methodArguments, { + 'apiKey': 'api-key', + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + 'sdkConfiguration': {'enableDebug': true, 'streamingEnabled': false}, + }); + }); + }); + + group('client', () { + test('get client with no keys', () { + _platform.getClient(matchingKey: 'matching-key', bucketingKey: null); + + expect(methodName, 'getClient'); + expect(methodArguments, {'matchingKey': 'matching-key'}); + }); + + test('get client with new matching key', () { + _platform.getClient(matchingKey: 'new-matching-key', bucketingKey: null); + + expect(methodName, 'getClient'); + expect(methodArguments, {'matchingKey': 'new-matching-key'}); + }); + + test('get client with new matching key and bucketing key', () { + _platform.getClient( + matchingKey: 'new-matching-key', bucketingKey: 'bucketing-key'); + + expect(methodName, 'getClient'); + expect(methodArguments, + {'matchingKey': 'new-matching-key', 'bucketingKey': 'bucketing-key'}); + }); + }); + + group('manager', () { + test('get split names', () { + _platform.splitNames(); + + expect(methodName, 'splitNames'); + }); + + test('get splits', () { + _platform.splits(); + + expect(methodName, 'splits'); + }); + + test('get split', () { + _platform.split(splitName: 'my_split'); + + expect(methodName, 'split'); + expect(methodArguments, {'splitName': 'my_split'}); + }); + }); + + group('events', () { + test('onReady', () { + _platform.getClient( + matchingKey: 'matching-key', bucketingKey: 'bucketing-key'); + + Future? onReady = _platform + .onReady(matchingKey: 'matching-key', bucketingKey: 'bucketing-key') + ?.then((value) => true); + + _simulateMethodInvocation('clientReady', + key: 'matching-key', bucketingKey: 'bucketing-key'); + + expect(onReady, completion(equals(true))); + }); + + test('onReadyFromCache', () { + _platform.getClient( + matchingKey: 'matching-key', bucketingKey: 'bucketing-key'); + + Future? onReadyFromCache = _platform + .onReadyFromCache( + matchingKey: 'matching-key', bucketingKey: 'bucketing-key') + ?.then((value) => true); + + _simulateMethodInvocation('clientReadyFromCache', + key: 'matching-key', bucketingKey: 'bucketing-key'); + + expect(onReadyFromCache, completion(equals(true))); + }); + + test('onTimeout', () { + _platform.getClient( + matchingKey: 'matching-key', bucketingKey: 'bucketing-key'); + + Future? onTimeout = _platform + .onTimeout(matchingKey: 'matching-key', bucketingKey: 'bucketing-key') + ?.then((value) => true); + + _simulateMethodInvocation('clientTimeout', + key: 'matching-key', bucketingKey: 'bucketing-key'); + + expect(onTimeout, completion(equals(true))); + }); + + test('onUpdated', () { + _platform.getClient( + matchingKey: 'matching-key', bucketingKey: 'bucketing-key'); + + Future? onUpdated = _platform + .onUpdated(matchingKey: 'matching-key', bucketingKey: 'bucketing-key') + ?.first + .then((value) => true); + + _simulateMethodInvocation('clientUpdated', + key: 'matching-key', bucketingKey: 'bucketing-key'); + + expect(onUpdated, completion(equals(true))); + }); + }); + + test('impressions', () { + _platform.impressionsStream().listen( + expectAsync1((impression) { + expect(impression.key, 'key'); + expect(impression.bucketingKey, null); + expect(impression.split, 'split'); + expect(impression.treatment, 'treatment'); + expect(impression.time, 3000); + expect(impression.appliedRule, 'appliedRule'); + expect(impression.changeNumber, 200); + expect(impression.attributes, {}); + }), + ); + _simulateMethodInvocation('impressionLog', key: 'matching-key', arguments: { + 'key': 'key', + 'bucketingKey': 'bucketingKey', + 'split': 'split', + 'treatment': 'treatment', + 'time': 3000, + 'appliedRule': 'appliedRule', + 'changeNumber': 200, + 'attributes': {} + }); + }); +} diff --git a/splitio_platform_interface/analysis_options.yaml b/splitio_platform_interface/analysis_options.yaml new file mode 100644 index 0000000..a5744c1 --- /dev/null +++ b/splitio_platform_interface/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/splitio_platform_interface/lib/method_channel_platform.dart b/splitio_platform_interface/lib/method_channel_platform.dart index b9a0513..b499305 100644 --- a/splitio_platform_interface/lib/method_channel_platform.dart +++ b/splitio_platform_interface/lib/method_channel_platform.dart @@ -1,32 +1,19 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; -import 'package:splitio_platform_interface/events/split_method_call_handler.dart'; -import 'package:splitio_platform_interface/impressions/impressions_method_call_handler.dart'; -import 'package:splitio_platform_interface/method_call_handler.dart'; -import 'package:splitio_platform_interface/split_configuration.dart'; -import 'package:splitio_platform_interface/split_impression.dart'; -import 'package:splitio_platform_interface/split_result.dart'; -import 'package:splitio_platform_interface/split_view.dart'; import 'package:splitio_platform_interface/splitio_platform_interface.dart'; const String _controlTreatment = 'control'; const SplitResult _controlResult = SplitResult(_controlTreatment, null); +const MethodChannel _methodChannel = MethodChannel('splitio'); class MethodChannelPlatform extends SplitioPlatform { - final MethodChannel _methodChannel = const MethodChannel('splitio'); + MethodChannel get methodChannel => _methodChannel; final Map _handlers = {}; final ImpressionsMethodCallHandler _impressionsMethodCallHandler = ImpressionsMethodCallHandler(); - MethodChannelPlatform() { - _methodChannel.setMethodCallHandler((call) => handle(call)); - } - - @visibleForTesting - MethodChannelPlatform.withoutHandler(); - @visibleForTesting Future handle(MethodCall call) async { _impressionsMethodCallHandler.handle(call.method, call.arguments); @@ -41,6 +28,8 @@ class MethodChannelPlatform extends SplitioPlatform { required String matchingKey, required String? bucketingKey, SplitConfiguration? sdkConfiguration}) { + methodChannel.setMethodCallHandler((call) => handle(call)); + Map arguments = { 'apiKey': apiKey, 'matchingKey': matchingKey, @@ -51,7 +40,7 @@ class MethodChannelPlatform extends SplitioPlatform { arguments.addAll({'bucketingKey': bucketingKey}); } - return _methodChannel.invokeMethod('init', arguments); + return methodChannel.invokeMethod('init', arguments); } @override @@ -62,14 +51,14 @@ class MethodChannelPlatform extends SplitioPlatform { SplitEventMethodCallHandler(matchingKey, bucketingKey) }); - return _methodChannel.invokeMethod( + return methodChannel.invokeMethod( 'getClient', _buildParameters(matchingKey, bucketingKey)); } @override Future clearAttributes( {required String matchingKey, required String? bucketingKey}) async { - return await _methodChannel.invokeMethod( + return await methodChannel.invokeMethod( 'clearAttributes', _buildParameters(matchingKey, bucketingKey)); } @@ -80,21 +69,21 @@ class MethodChannelPlatform extends SplitioPlatform { _handlers[handlerKey]?.destroy(); _handlers.remove(handlerKey); - return await _methodChannel.invokeMethod( + return await methodChannel.invokeMethod( 'destroy', _buildParameters(matchingKey, bucketingKey)); } @override Future flush( {required String matchingKey, required String? bucketingKey}) async { - return await _methodChannel.invokeMethod( + return await methodChannel.invokeMethod( 'flush', _buildParameters(matchingKey, bucketingKey)); } @override Future> getAllAttributes( {required String matchingKey, required String? bucketingKey}) async { - return (await _methodChannel.invokeMapMethod('getAllAttributes', + return (await methodChannel.invokeMapMethod('getAllAttributes', _buildParameters(matchingKey, bucketingKey))) ?.map((key, value) => MapEntry(key, value)) ?? {}; @@ -105,7 +94,7 @@ class MethodChannelPlatform extends SplitioPlatform { {required String matchingKey, required String? bucketingKey, required String attributeName}) { - return _methodChannel.invokeMethod( + return methodChannel.invokeMethod( 'getAttribute', _buildParameters( matchingKey, bucketingKey, {'attributeName': attributeName})); @@ -117,7 +106,7 @@ class MethodChannelPlatform extends SplitioPlatform { required String? bucketingKey, required String splitName, Map attributes = const {}}) async { - return await _methodChannel.invokeMethod( + return await methodChannel.invokeMethod( 'getTreatment', _buildParameters(matchingKey, bucketingKey, {'splitName': splitName, 'attributes': attributes})) ?? @@ -130,7 +119,7 @@ class MethodChannelPlatform extends SplitioPlatform { required String? bucketingKey, required String splitName, Map attributes = const {}}) async { - Map? treatment = (await _methodChannel.invokeMapMethod( + Map? treatment = (await methodChannel.invokeMapMethod( 'getTreatmentWithConfig', _buildParameters(matchingKey, bucketingKey, {'splitName': splitName, 'attributes': attributes}))) @@ -150,7 +139,7 @@ class MethodChannelPlatform extends SplitioPlatform { required String? bucketingKey, required List splitNames, Map attributes = const {}}) async { - Map? treatments = await _methodChannel.invokeMapMethod( + Map? treatments = await methodChannel.invokeMapMethod( 'getTreatments', _buildParameters(matchingKey, bucketingKey, {'splitName': splitNames, 'attributes': attributes})); @@ -166,7 +155,7 @@ class MethodChannelPlatform extends SplitioPlatform { required String? bucketingKey, required List splitNames, Map attributes = const {}}) async { - Map? treatments = await _methodChannel.invokeMapMethod( + Map? treatments = await methodChannel.invokeMapMethod( 'getTreatmentsWithConfig', _buildParameters(matchingKey, bucketingKey, {'splitName': splitNames, 'attributes': attributes})); @@ -181,7 +170,7 @@ class MethodChannelPlatform extends SplitioPlatform { {required String matchingKey, required String? bucketingKey, required String attributeName}) async { - return await _methodChannel.invokeMethod( + return await methodChannel.invokeMethod( 'removeAttribute', _buildParameters( matchingKey, bucketingKey, {'attributeName': attributeName})); @@ -193,7 +182,7 @@ class MethodChannelPlatform extends SplitioPlatform { required String? bucketingKey, required String attributeName, required value}) async { - var result = await _methodChannel.invokeMethod( + var result = await methodChannel.invokeMethod( 'setAttribute', _buildParameters(matchingKey, bucketingKey, {'attributeName': attributeName, 'value': value})); @@ -210,7 +199,7 @@ class MethodChannelPlatform extends SplitioPlatform { {required String matchingKey, required String? bucketingKey, required Map attributes}) async { - var result = await _methodChannel.invokeMethod( + var result = await methodChannel.invokeMethod( 'setAttributes', _buildParameters( matchingKey, bucketingKey, {'attributes': attributes})); @@ -225,7 +214,7 @@ class MethodChannelPlatform extends SplitioPlatform { @override Future split({required String splitName}) async { Map? mapResult = - await _methodChannel.invokeMapMethod('split', {'splitName': splitName}); + await methodChannel.invokeMapMethod('split', {'splitName': splitName}); if (mapResult == null) { return null; @@ -237,14 +226,14 @@ class MethodChannelPlatform extends SplitioPlatform { @override Future> splitNames() async { List splitNames = - await _methodChannel.invokeListMethod('splitNames') ?? []; + await methodChannel.invokeListMethod('splitNames') ?? []; return splitNames; } @override Future> splits() async { - List callResult = (await _methodChannel + List callResult = (await methodChannel .invokeListMethod>('splits') ?? []); @@ -279,7 +268,7 @@ class MethodChannelPlatform extends SplitioPlatform { } try { - return await _methodChannel.invokeMethod('track', parameters) as bool; + return await methodChannel.invokeMethod('track', parameters) as bool; } on Exception catch (_) { return false; } diff --git a/splitio_platform_interface/lib/split_sync_config.dart b/splitio_platform_interface/lib/split_sync_config.dart index 8e59b20..6eec23d 100644 --- a/splitio_platform_interface/lib/split_sync_config.dart +++ b/splitio_platform_interface/lib/split_sync_config.dart @@ -1,12 +1,19 @@ class SyncConfig { - late final Set _names; - late final Set _prefixes; + late Set _names; + late Set _prefixes; Set get names => _names; Set get prefixes => _prefixes; - SyncConfig({Set names = const {}, Set prefixes = const {}}) { + SyncConfig( + {List names = const [], List prefixes = const []}) { + _names = names.toSet(); + _prefixes = prefixes.toSet(); + } + + SyncConfig.fromSet( + {Set names = const {}, Set prefixes = const {}}) { _names = names; _prefixes = prefixes; } diff --git a/splitio_platform_interface/lib/splitio_platform_interface.dart b/splitio_platform_interface/lib/splitio_platform_interface.dart index 71c97ea..729e001 100644 --- a/splitio_platform_interface/lib/splitio_platform_interface.dart +++ b/splitio_platform_interface/lib/splitio_platform_interface.dart @@ -7,6 +7,16 @@ import 'package:splitio_platform_interface/split_impression.dart'; import 'package:splitio_platform_interface/split_result.dart'; import 'package:splitio_platform_interface/split_view.dart'; +export 'package:splitio_platform_interface/events/split_method_call_handler.dart'; +export 'package:splitio_platform_interface/impressions/impressions_method_call_handler.dart'; +export 'package:splitio_platform_interface/method_call_handler.dart'; +export 'package:splitio_platform_interface/method_channel_platform.dart'; +export 'package:splitio_platform_interface/split_configuration.dart'; +export 'package:splitio_platform_interface/split_impression.dart'; +export 'package:splitio_platform_interface/split_result.dart'; +export 'package:splitio_platform_interface/split_view.dart'; +export 'package:splitio_platform_interface/splitio_platform_interface.dart'; + abstract class _FactoryPlatform { Future getClient( {required String matchingKey, required String? bucketingKey}) { @@ -22,8 +32,7 @@ abstract class _FactoryPlatform { throw UnimplementedError(); } - Future split({ - required String splitName}) { + Future split({required String splitName}) { throw UnimplementedError(); } diff --git a/splitio_platform_interface/pubspec.yaml b/splitio_platform_interface/pubspec.yaml index 0d43036..4331e21 100644 --- a/splitio_platform_interface/pubspec.yaml +++ b/splitio_platform_interface/pubspec.yaml @@ -6,7 +6,7 @@ version: 1.0.0 homepage: https://split.io/ repository: https://github.com/splitio/flutter-sdk-plugin/splitio/splitio_platform_interface -publish_to: none +publish_to: 'none' environment: sdk: ">=2.16.2 <3.0.0" diff --git a/splitio_platform_interface/test/impressions_method_call_handler_test.dart b/splitio_platform_interface/test/impressions_method_call_handler_test.dart index 8222156..f6836bd 100644 --- a/splitio_platform_interface/test/impressions_method_call_handler_test.dart +++ b/splitio_platform_interface/test/impressions_method_call_handler_test.dart @@ -1,6 +1,7 @@ import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:splitio_platform_interface/impressions/impressions_method_call_handler.dart'; +import 'package:splitio_platform_interface/split_impression.dart'; void main() { test('correct impressionLog method call emits value on stream', () async { diff --git a/splitio_platform_interface/test/method_channel_platform_test.dart b/splitio_platform_interface/test/method_channel_platform_test.dart index ee51457..9f5ee07 100644 --- a/splitio_platform_interface/test/method_channel_platform_test.dart +++ b/splitio_platform_interface/test/method_channel_platform_test.dart @@ -11,15 +11,13 @@ void main() { TestWidgetsFlutterBinding.ensureInitialized(); - MethodChannelPlatform _platform = MethodChannelPlatform.withoutHandler(); + MethodChannelPlatform _platform = MethodChannelPlatform(); void _simulateMethodInvocation(String methodName, {String key = 'key', String? bucketingKey, Map? arguments}) { - if (arguments == null) { - arguments = {}; - } + arguments ??= {}; arguments.addAll({'matchingKey': key, 'bucketingKey': bucketingKey}); _channel.invokeMethod(methodName, arguments); }