diff --git a/splitio/example/pubspec.lock b/splitio/example/pubspec.lock index 3d5ec72..1de670f 100644 --- a/splitio/example/pubspec.lock +++ b/splitio/example/pubspec.lock @@ -109,6 +109,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.0" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.2" sky_engine: dependency: transitive description: flutter @@ -128,6 +135,13 @@ packages: relative: true source: path version: "0.1.1" + splitio_platform_interface: + dependency: transitive + description: + path: "../../splitio_platform_interface" + relative: true + source: path + version: "1.0.0" stack_trace: dependency: transitive description: diff --git a/splitio/lib/split_client.dart b/splitio/lib/split_client.dart index fb72ce0..ec333b6 100644 --- a/splitio/lib/split_client.dart +++ b/splitio/lib/split_client.dart @@ -1,8 +1,6 @@ import 'package:flutter/foundation.dart'; -import 'package:splitio/channel/method_channel_manager.dart'; -import 'package:splitio/events/split_events_listener.dart'; -import 'package:splitio/events/split_method_call_handler.dart'; -import 'package:splitio/split_result.dart'; +import 'package:splitio_platform_interface/split_result.dart'; +import 'package:splitio_platform_interface/splitio_platform_interface.dart'; abstract class SplitClient { /// Performs an evaluation for the [splitName] feature. @@ -142,79 +140,55 @@ abstract class SplitClient { } class DefaultSplitClient implements SplitClient { - static const String _controlTreatment = 'control'; - static const SplitResult _controlResult = - SplitResult(_controlTreatment, null); - - final MethodChannelManager _methodChannelManager; - late final SplitEventMethodCallHandler _methodCallHandler; + final SplitioPlatform _platform; final String _matchingKey; final String? _bucketingKey; - late final SplitEventsListener _splitEventsListener; - - DefaultSplitClient( - this._methodChannelManager, this._matchingKey, this._bucketingKey) { - _methodCallHandler = - SplitEventMethodCallHandler(_matchingKey, _bucketingKey, this); - _splitEventsListener = - DefaultEventsListener(_methodChannelManager, _methodCallHandler); - } + DefaultSplitClient(this._platform, this._matchingKey, this._bucketingKey); @visibleForTesting - DefaultSplitClient.withEventListener(this._methodChannelManager, - this._matchingKey, this._bucketingKey, this._splitEventsListener); + DefaultSplitClient.withEventListener( + this._platform, this._matchingKey, this._bucketingKey); @override Future getTreatment(String splitName, [Map attributes = const {}]) async { - return await _methodChannelManager.invokeMethod( - 'getTreatment', - _buildParameters( - {'splitName': splitName, 'attributes': attributes})) ?? - _controlTreatment; + return _platform.getTreatment( + matchingKey: _matchingKey, + bucketingKey: _bucketingKey, + splitName: splitName, + attributes: attributes); } @override Future getTreatmentWithConfig(String splitName, [Map attributes = const {}]) async { - Map? treatment = (await _methodChannelManager.invokeMapMethod( - 'getTreatmentWithConfig', - _buildParameters( - {'splitName': splitName, 'attributes': attributes}))) - ?.entries - .first - .value; - if (treatment == null) { - return _controlResult; - } - - return SplitResult(treatment['treatment'], treatment['config']); + return _platform.getTreatmentWithConfig( + matchingKey: _matchingKey, + bucketingKey: _bucketingKey, + splitName: splitName, + attributes: attributes); } @override Future> getTreatments(List splitNames, [Map attributes = const {}]) async { - Map? treatments = await _methodChannelManager.invokeMapMethod( - 'getTreatments', - _buildParameters({'splitName': splitNames, 'attributes': attributes})); - - return treatments - ?.map((key, value) => MapEntry(key, value)) ?? - {for (var item in splitNames) item: _controlTreatment}; + return _platform.getTreatments( + matchingKey: _matchingKey, + bucketingKey: _bucketingKey, + splitNames: splitNames, + attributes: attributes); } @override Future> getTreatmentsWithConfig( List splitNames, [Map attributes = const {}]) async { - Map? treatments = await _methodChannelManager.invokeMapMethod( - 'getTreatmentsWithConfig', - _buildParameters({'splitName': splitNames, 'attributes': attributes})); - - return treatments?.map((key, value) => - MapEntry(key, SplitResult(value['treatment'], value['config']))) ?? - {for (var item in splitNames) item: _controlResult}; + return _platform.getTreatmentsWithConfig( + matchingKey: _matchingKey, + bucketingKey: _bucketingKey, + splitNames: splitNames, + attributes: attributes); } @override @@ -222,121 +196,101 @@ class DefaultSplitClient implements SplitClient { {String? trafficType, double? value, Map properties = const {}}) async { - var parameters = _buildParameters({'eventType': eventType}); - - if (trafficType != null) { - parameters['trafficType'] = trafficType; - } - - if (value != null) { - parameters['value'] = value; - } - - try { - return await _methodChannelManager.invokeMethod("track", parameters) - as bool; - } on Exception catch (_) { - return false; - } + return _platform.track( + matchingKey: _matchingKey, + bucketingKey: _bucketingKey, + eventType: eventType, + trafficType: trafficType, + value: value, + properties: properties); } @override Future setAttribute(String attributeName, dynamic value) async { - var result = await _methodChannelManager.invokeMethod('setAttribute', - _buildParameters({'attributeName': attributeName, 'value': value})); - - if (result is bool) { - return result; - } - - return false; + return _platform.setAttribute( + matchingKey: _matchingKey, + bucketingKey: _bucketingKey, + attributeName: attributeName, + value: value); } @override Future getAttribute(String attributeName) async { - return _methodChannelManager.invokeMethod( - 'getAttribute', _buildParameters({'attributeName': attributeName})); + return _platform.getAttribute( + matchingKey: _matchingKey, + bucketingKey: _bucketingKey, + attributeName: attributeName); } @override Future setAttributes(Map attributes) async { - var result = await _methodChannelManager.invokeMethod( - 'setAttributes', _buildParameters({'attributes': attributes})); - - if (result is bool) { - return result; - } - - return false; + return _platform.setAttributes( + matchingKey: _matchingKey, + bucketingKey: _bucketingKey, + attributes: attributes); } @override Future> getAttributes() async { - return (await _methodChannelManager.invokeMapMethod( - 'getAllAttributes', _buildParameters())) - ?.map((key, value) => MapEntry(key, value)) ?? - {}; + return _platform.getAllAttributes( + matchingKey: _matchingKey, bucketingKey: _bucketingKey); } @override Future removeAttribute(String attributeName) async { - return await _methodChannelManager.invokeMethod( - 'removeAttribute', _buildParameters({'attributeName': attributeName})); + return _platform.removeAttribute( + matchingKey: _matchingKey, + bucketingKey: _bucketingKey, + attributeName: attributeName); } @override Future clearAttributes() async { - return await _methodChannelManager.invokeMethod( - 'clearAttributes', _buildParameters()); + return _platform.clearAttributes( + matchingKey: _matchingKey, bucketingKey: _bucketingKey); } @override Future flush() async { - return _methodChannelManager.invokeMethod('flush', _buildParameters()); + return _platform.flush( + matchingKey: _matchingKey, bucketingKey: _bucketingKey); } @override Future destroy() async { - _splitEventsListener.destroy(); - return _methodChannelManager.invokeMethod('destroy', _buildParameters()); + return _platform.destroy( + matchingKey: _matchingKey, bucketingKey: _bucketingKey); } @override - Future whenReady() { - return _splitEventsListener.onReady(); + Future whenReady() async { + await _platform.onReady( + matchingKey: _matchingKey, bucketingKey: _bucketingKey); + + return Future.value(this); } @override - Future whenReadyFromCache() { - return _splitEventsListener.onReadyFromCache(); + Future whenReadyFromCache() async { + await _platform.onReadyFromCache( + matchingKey: _matchingKey, bucketingKey: _bucketingKey); + + return Future.value(this); } @override Stream whenUpdated() { - return _splitEventsListener.onUpdated(); + return _platform + .onUpdated(matchingKey: _matchingKey, bucketingKey: _bucketingKey) + ?.map((event) => this) ?? + const Stream.empty(); } @override - Future whenTimeout() { - return _splitEventsListener.onTimeout(); - } - - Map _getKeysMap() { - Map result = {'matchingKey': _matchingKey}; - - if (_bucketingKey != null) { - result.addAll({'bucketingKey': _bucketingKey!}); - } - - return result; - } - - Map _buildParameters( - [Map parameters = const {}]) { - Map result = {}; - result.addAll(parameters); - result.addAll(_getKeysMap()); + Future whenTimeout() async { + await _platform.onTimeout( + matchingKey: _matchingKey, bucketingKey: _bucketingKey); - return result; + return Future.value(this); } } diff --git a/splitio/lib/splitio.dart b/splitio/lib/splitio.dart index 254a486..203153e 100644 --- a/splitio/lib/splitio.dart +++ b/splitio/lib/splitio.dart @@ -1,31 +1,28 @@ import 'dart:async'; -import 'package:flutter/services.dart'; -import 'package:splitio/channel/method_channel_manager.dart'; -import 'package:splitio/impressions/impressions_method_call_handler.dart'; -import 'package:splitio/impressions/split_impression.dart'; -import 'package:splitio/method_call_handler.dart'; import 'package:splitio/split_client.dart'; -import 'package:splitio/split_configuration.dart'; -import 'package:splitio/split_view.dart'; +import 'package:splitio_platform_interface/split_configuration.dart'; +import 'package:splitio_platform_interface/split_impression.dart'; +import 'package:splitio_platform_interface/split_view.dart'; +import 'package:splitio_platform_interface/splitio_platform_interface.dart'; -export 'package:splitio/impressions/split_impression.dart'; export 'package:splitio/split_client.dart'; -export 'package:splitio/split_configuration.dart'; -export 'package:splitio/split_result.dart'; -export 'package:splitio/split_sync_config.dart'; -export 'package:splitio/split_view.dart'; +export 'package:splitio_platform_interface/split_configuration.dart'; +export 'package:splitio_platform_interface/split_impression.dart'; +export 'package:splitio_platform_interface/split_view.dart'; typedef ClientReadinessCallback = void Function(SplitClient splitClient); class Splitio { final String _apiKey; + final String _defaultMatchingKey; + late final String? _defaultBucketingKey; + late final SplitConfiguration? _splitConfiguration; - late final StreamMethodCallHandler _impressionsMethodCallHandler; - final MethodChannelManager _methodChannelManager = - MethodChannelManager(const MethodChannel('splitio')); + + final SplitioPlatform _platform = SplitioPlatform.instance; /// SDK instance constructor. /// @@ -41,8 +38,6 @@ class Splitio { {String? bucketingKey, SplitConfiguration? configuration}) { _defaultBucketingKey = bucketingKey; _splitConfiguration = configuration; - _impressionsMethodCallHandler = ImpressionsMethodCallHandler(); - _methodChannelManager.addHandler(_impressionsMethodCallHandler); _init(); } @@ -77,97 +72,66 @@ class Splitio { ClientReadinessCallback? onUpdated, ClientReadinessCallback? onTimeout}) { String? key = matchingKey ?? _defaultMatchingKey; + _platform.getClient(matchingKey: key, bucketingKey: bucketingKey); - var client = DefaultSplitClient(_methodChannelManager, key, bucketingKey); + var client = DefaultSplitClient(_platform, key, bucketingKey); if (onReady != null) { - client.whenReady().then((client) => onReady.call(client)); + _platform + .onReady(matchingKey: key, bucketingKey: bucketingKey) + ?.then((val) => onReady.call(client)); } if (onReadyFromCache != null) { - client - .whenReadyFromCache() - .then((client) => onReadyFromCache.call(client)); + _platform + .onReadyFromCache(matchingKey: key, bucketingKey: bucketingKey) + ?.then((val) => onReadyFromCache.call(client)); } if (onTimeout != null) { - client.whenTimeout().then((client) => onTimeout.call(client)); + _platform + .onTimeout(matchingKey: key, bucketingKey: bucketingKey) + ?.then((val) => onTimeout.call(client)); } if (onUpdated != null) { - client.whenUpdated().listen((client) => onUpdated.call(client)); + _platform + .onUpdated(matchingKey: key, bucketingKey: bucketingKey) + ?.listen((event) => onUpdated.call(client)); } - _methodChannelManager.invokeMethod( - 'getClient', _buildGetClientArguments(key, bucketingKey)); - return client; } Future> splitNames() async { - List splitNames = - await _methodChannelManager.invokeListMethod('splitNames') ?? - []; + List splitNames = await _platform.splitNames( + matchingKey: _defaultMatchingKey, bucketingKey: _defaultBucketingKey); return splitNames; } Future> splits() async { - List callResult = (await _methodChannelManager - .invokeListMethod>('splits') ?? - []); - - List splits = []; - for (var element in callResult) { - SplitView? splitView = SplitView.fromEntry(element); - if (splitView != null) { - splits.add(splitView); - } - } - - return Future.value(splits); + return _platform.splits( + matchingKey: _defaultMatchingKey, bucketingKey: _defaultBucketingKey); } /// If the impressionListener configuration has been enabled, /// generated impressions will be streamed here. Stream impressionsStream() { - return _impressionsMethodCallHandler.stream(); + return _platform.impressionsStream(); } Future split(String splitName) async { - Map? mapResult = await _methodChannelManager - .invokeMapMethod('split', {'splitName': splitName}); - - if (mapResult == null) { - return null; - } - - return SplitView.fromEntry(mapResult); + return _platform.split( + matchingKey: _defaultMatchingKey, + bucketingKey: _defaultBucketingKey, + splitName: splitName); } Future _init() { - Map arguments = { - 'apiKey': _apiKey, - 'matchingKey': _defaultMatchingKey, - 'sdkConfiguration': _splitConfiguration?.configurationMap ?? {}, - }; - - if (_defaultBucketingKey != null) { - arguments.addAll({'bucketingKey': _defaultBucketingKey}); - } - - return _methodChannelManager.invokeMethod('init', arguments); - } - - Map _buildGetClientArguments( - String key, String? bucketingKey) { - var arguments = { - 'matchingKey': key, - }; - - if (bucketingKey != null) { - arguments.addAll({'bucketingKey': bucketingKey}); - } - - return arguments; + return _platform.init( + apiKey: _apiKey, + matchingKey: _defaultMatchingKey, + bucketingKey: _defaultBucketingKey, + sdkConfiguration: _splitConfiguration); } } diff --git a/splitio/pubspec.yaml b/splitio/pubspec.yaml index a4f85a3..ddc7878 100644 --- a/splitio/pubspec.yaml +++ b/splitio/pubspec.yaml @@ -11,6 +11,8 @@ environment: dependencies: flutter: sdk: flutter + splitio_platform_interface: # ^1.0.0 + path: ../splitio_platform_interface dev_dependencies: flutter_test: diff --git a/splitio/test/splitio_client_test.dart b/splitio/test/splitio_client_test.dart index 52e7a44..0babeb2 100644 --- a/splitio/test/splitio_client_test.dart +++ b/splitio/test/splitio_client_test.dart @@ -1,7 +1,5 @@ import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:splitio/channel/method_channel_manager.dart'; -import 'package:splitio/events/split_events_listener.dart'; import 'package:splitio/split_client.dart'; void main() { diff --git a/splitio_platform_interface/lib/method_channel_platform.dart b/splitio_platform_interface/lib/method_channel_platform.dart new file mode 100644 index 0000000..95ff186 --- /dev/null +++ b/splitio_platform_interface/lib/method_channel_platform.dart @@ -0,0 +1,332 @@ + +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); + +class MethodChannelPlatform extends SplitioPlatform { + + final MethodChannel _methodChannel = const MethodChannel('splitio'); + + final Map _handlers = {}; + + final ImpressionsMethodCallHandler _impressionsMethodCallHandler = ImpressionsMethodCallHandler(); + + MethodChannelPlatform() { + _methodChannel.setMethodCallHandler((call) => handle(call)); + } + + @visibleForTesting + Future handle(MethodCall call) async { + _impressionsMethodCallHandler.handle(call.method, call.arguments); + for (MethodCallHandler handler in _handlers.values) { + handler.handle(call.method, call.arguments); + } + } + + @override + Future init({required String apiKey, + required String matchingKey, + required String? bucketingKey, + SplitConfiguration? sdkConfiguration}) { + Map arguments = { + 'apiKey': apiKey, + 'matchingKey': matchingKey, + 'sdkConfiguration': sdkConfiguration?.configurationMap ?? {}, + }; + + if (bucketingKey != null) { + arguments.addAll({'bucketingKey': bucketingKey}); + } + + return _methodChannel.invokeMethod('init', arguments); + } + + @override + Future getClient( + {required String matchingKey, required String? bucketingKey}) { + _handlers.addAll( + { + _buildMapKey(matchingKey, bucketingKey): SplitEventMethodCallHandler( + matchingKey, bucketingKey) + }); + + return _methodChannel.invokeMethod( + 'getClient', _buildParameters(matchingKey, bucketingKey)); + } + + @override + Future clearAttributes( + {required String matchingKey, required String? bucketingKey}) async { + return await _methodChannel.invokeMethod( + 'clearAttributes', _buildParameters(matchingKey, bucketingKey)); + } + + @override + Future destroy( + {required String matchingKey, required String? bucketingKey}) async { + var handlerKey = _buildMapKey(matchingKey, bucketingKey); + _handlers[handlerKey]?.destroy(); + _handlers.remove(handlerKey); + + return await _methodChannel.invokeMethod( + 'destroy', _buildParameters(matchingKey, bucketingKey)); + } + + @override + Future flush( + {required String matchingKey, required String? bucketingKey}) async { + return await _methodChannel.invokeMethod( + 'flush', _buildParameters(matchingKey, bucketingKey)); + } + + @override + Future> getAllAttributes( + {required String matchingKey, required String? bucketingKey}) async { + return (await _methodChannel.invokeMapMethod( + 'getAllAttributes', _buildParameters(matchingKey, bucketingKey))) + ?.map((key, value) => MapEntry(key, value)) ?? + {}; + } + + @override + Future getAttribute({required String matchingKey, + required String? bucketingKey, + required String attributeName}) { + return _methodChannel.invokeMethod( + 'getAttribute', _buildParameters( + matchingKey, bucketingKey, {'attributeName': attributeName})); + } + + @override + Future getTreatment({required String matchingKey, + required String? bucketingKey, + required String splitName, + Map attributes = const {}}) async { + return await _methodChannel.invokeMethod( + 'getTreatment', + _buildParameters(matchingKey, bucketingKey, + {'splitName': splitName, 'attributes': attributes})) ?? + _controlTreatment; + } + + @override + Future getTreatmentWithConfig({required String matchingKey, + required String? bucketingKey, + required String splitName, + Map attributes = const {}}) async { + Map? treatment = (await _methodChannel.invokeMapMethod( + 'getTreatmentWithConfig', + _buildParameters(matchingKey, bucketingKey + {'splitName': splitName, 'attributes': attributes}))) + ?.entries + .first + .value; + if (treatment == null) { + return _controlResult; + } + + return SplitResult(treatment['treatment'], treatment['config']); + } + + @override + Future> getTreatments({required String matchingKey, + required String? bucketingKey, + required List splitNames, + Map attributes = const {}}) async { + Map? treatments = await _methodChannel.invokeMapMethod( + 'getTreatments', + _buildParameters(matchingKey, bucketingKey, + {'splitName': splitNames, 'attributes': attributes})); + + return treatments + ?.map((key, value) => MapEntry(key, value)) ?? + {for (var item in splitNames) item: _controlTreatment}; + } + + @override + Future> getTreatmentsWithConfig( + {required String matchingKey, + required String? bucketingKey, + required List splitNames, + Map attributes = const {}}) async { + Map? treatments = await _methodChannel.invokeMapMethod( + 'getTreatmentsWithConfig', + _buildParameters(matchingKey, bucketingKey, + {'splitName': splitNames, 'attributes': attributes})); + + return treatments?.map((key, value) => + MapEntry(key, SplitResult(value['treatment'], value['config']))) ?? + {for (var item in splitNames) item: _controlResult}; + } + + @override + Future removeAttribute({required String matchingKey, + required String? bucketingKey, + required String attributeName}) async { + return await _methodChannel.invokeMethod( + 'removeAttribute', _buildParameters( + matchingKey, bucketingKey, {'attributeName': attributeName})); + } + + @override + Future setAttribute({required String matchingKey, + required String? bucketingKey, + required String attributeName, + required value}) async { + var result = await _methodChannel.invokeMethod('setAttribute', + _buildParameters(matchingKey, bucketingKey, + {'attributeName': attributeName, 'value': value})); + + if (result is bool) { + return result; + } + + return false; + } + + @override + Future setAttributes({required String matchingKey, + required String? bucketingKey, + required Map attributes}) async { + var result = await _methodChannel.invokeMethod( + 'setAttributes', _buildParameters( + matchingKey, bucketingKey, {'attributes': attributes})); + + if (result is bool) { + return result; + } + + return false; + } + + @override + Future split({required String matchingKey, + required String? bucketingKey, + required String splitName}) async { + Map? mapResult = + await _methodChannel.invokeMapMethod('split', {'splitName': splitName}); + + if (mapResult == null) { + return null; + } + + return SplitView.fromEntry(mapResult); + } + + @override + Future> splitNames( + {required String matchingKey, required String? bucketingKey}) async { + List splitNames = + await _methodChannel.invokeListMethod('splitNames') ?? []; + + return splitNames; + } + + @override + Future> splits( + {required String matchingKey, required String? bucketingKey}) async { + List callResult = (await _methodChannel + .invokeListMethod>('splits') ?? + []); + + List splits = []; + for (var element in callResult) { + SplitView? splitView = SplitView.fromEntry(element); + if (splitView != null) { + splits.add(splitView); + } + } + + return Future.value(splits); + } + + @override + Future track({required String matchingKey, + required String? bucketingKey, + required String eventType, + String? trafficType, + double? value, + Map properties = const {}}) async { + var parameters = _buildParameters( + matchingKey, bucketingKey, {'eventType': eventType}); + + if (trafficType != null) { + parameters['trafficType'] = trafficType; + } + + if (value != null) { + parameters['value'] = value; + } + + try { + return await _methodChannel.invokeMethod("track", parameters) + as bool; + } on Exception catch (_) { + return false; + } + } + + Map _buildParameters(String matchingKey, + String? bucketingKey, + [Map parameters = const {}]) { + Map result = {}; + result.addAll(parameters); + result.addAll(_getKeysMap(matchingKey, bucketingKey)); + + return result; + } + + Map _getKeysMap(String matchingKey, String? bucketingKey) { + Map result = {'matchingKey': matchingKey}; + + if (bucketingKey != null) { + result.addAll({'bucketingKey': bucketingKey}); + } + + return result; + } + + @override + Future? onReady( + {required String matchingKey, required String? bucketingKey}) { + return _handlers[_buildMapKey(matchingKey, bucketingKey)]?.onReady(); + } + + @override + Future? onReadyFromCache( + {required String matchingKey, required String? bucketingKey}) { + return _handlers[_buildMapKey(matchingKey, bucketingKey)] + ?.onReadyFromCache(); + } + + @override + Stream? onUpdated( + {required String matchingKey, required String? bucketingKey}) { + return _handlers[_buildMapKey(matchingKey, bucketingKey)]?.onUpdated(); + } + + @override + Future? onTimeout( + {required String matchingKey, required String? bucketingKey}) { + return _handlers[_buildMapKey(matchingKey, bucketingKey)]?.onTimeout(); + } + + @override + Stream impressionsStream() { + return _impressionsMethodCallHandler.stream(); + } + + String _buildMapKey(String matchingKey, String? bucketingKey) { + return '${matchingKey}_$bucketingKey'; + } +} diff --git a/splitio_platform_interface/lib/split_configuration.dart b/splitio_platform_interface/lib/split_configuration.dart index 5e93df9..80c55fb 100644 --- a/splitio_platform_interface/lib/split_configuration.dart +++ b/splitio_platform_interface/lib/split_configuration.dart @@ -1,4 +1,4 @@ -import 'package:splitio/split_sync_config.dart'; +import 'package:splitio_platform_interface/split_sync_config.dart'; class SplitConfiguration { final Map configurationMap = {}; 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 f919f9a..6ae0cbb 100644 --- a/splitio_platform_interface/test/impressions_method_call_handler_test.dart +++ b/splitio_platform_interface/test/impressions_method_call_handler_test.dart @@ -1,8 +1,9 @@ import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:splitio/impressions/impressions_method_call_handler.dart'; import 'package:splitio/impressions/split_impression.dart'; +import '../lib/impressions/impressions_method_call_handler.dart'; + void main() { test('correct impressionLog method call emits value on stream', () async { const Map sourceMap = { @@ -34,8 +35,9 @@ void main() { }), ); - impressionsMethodCallHandler - .handle(const MethodCall('impressionLog', sourceMap)); + const methodCall = MethodCall('impressionLog', sourceMap); + impressionsMethodCallHandler.handle( + methodCall.method, methodCall.arguments); }); test('other method names are ignored', () async { @@ -47,6 +49,8 @@ void main() { expect(event, null); }, count: 0), ); - impressionsMethodCallHandler.handle(const MethodCall('clientReady')); + const methodCall = MethodCall('clientReady'); + impressionsMethodCallHandler.handle( + methodCall.method, methodCall.arguments); }); } diff --git a/splitio_platform_interface/test/split_event_listener_test.dart b/splitio_platform_interface/test/split_event_listener_test.dart index 3099e8f..f06c463 100644 --- a/splitio_platform_interface/test/split_event_listener_test.dart +++ b/splitio_platform_interface/test/split_event_listener_test.dart @@ -3,9 +3,10 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:splitio/channel/method_channel_manager.dart'; import 'package:splitio/events/split_events_listener.dart'; import 'package:splitio/events/split_method_call_handler.dart'; -import 'package:splitio/split_client.dart'; import 'package:splitio/split_result.dart'; +import '../lib/split_client.dart'; + void main() { const MethodChannel _channel = MethodChannel('splitio'); @@ -25,7 +26,8 @@ void main() { setUp(() { _channel.setMockMethodCallHandler((MethodCall methodCall) { - splitEventMethodCallHandler.handle(methodCall); + splitEventMethodCallHandler.handle( + methodCall.method, methodCall.arguments); }); });