feat(interface): make api injectable for test
This commit is contained in:
parent
d8cf8dddc4
commit
8044ccfa43
@ -13,3 +13,5 @@ export 'src/core/exceptions/exception.dart';
|
|||||||
export 'src/implementations/basic_message_channel_native_crypto.dart';
|
export 'src/implementations/basic_message_channel_native_crypto.dart';
|
||||||
export 'src/implementations/method_channel_native_crypto.dart';
|
export 'src/implementations/method_channel_native_crypto.dart';
|
||||||
export 'src/interface/native_crypto_platform.dart';
|
export 'src/interface/native_crypto_platform.dart';
|
||||||
|
export 'src/pigeon/messages.pigeon.dart';
|
||||||
|
export 'src/pigeon/test_api.dart';
|
||||||
|
@ -6,13 +6,18 @@
|
|||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:native_crypto_platform_interface/native_crypto_platform_interface.dart';
|
import 'package:native_crypto_platform_interface/native_crypto_platform_interface.dart';
|
||||||
import 'package:native_crypto_platform_interface/src/pigeon/messages.pigeon.dart';
|
|
||||||
|
|
||||||
/// An implementation of [NativeCryptoPlatform] that uses Pigeon generated code.
|
/// An implementation of [NativeCryptoPlatform] that uses Pigeon generated code.
|
||||||
class BasicMessageChannelNativeCrypto extends NativeCryptoPlatform {
|
class BasicMessageChannelNativeCrypto extends NativeCryptoPlatform {
|
||||||
|
/// Creates a new instance of [BasicMessageChannelNativeCrypto].
|
||||||
|
///
|
||||||
|
/// The [api] parameter permits to override the default Pigeon API used to
|
||||||
|
/// interact with the native platform. This is useful for testing.
|
||||||
|
BasicMessageChannelNativeCrypto({NativeCryptoAPI? api})
|
||||||
|
: api = api ?? NativeCryptoAPI();
|
||||||
|
|
||||||
/// The Pigeon API used to interact with the native platform.
|
/// The Pigeon API used to interact with the native platform.
|
||||||
@visibleForTesting
|
final NativeCryptoAPI api;
|
||||||
NativeCryptoAPI api = NativeCryptoAPI();
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<Uint8List?> hash(Uint8List data, {required String algorithm}) async {
|
Future<Uint8List?> hash(Uint8List data, {required String algorithm}) async {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user