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/method_channel_native_crypto.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: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.
|
||||
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.
|
||||
@visibleForTesting
|
||||
NativeCryptoAPI api = NativeCryptoAPI();
|
||||
final NativeCryptoAPI api;
|
||||
|
||||
@override
|
||||
Future<Uint8List?> hash(Uint8List data, {required String algorithm}) async {
|
||||
|
Loading…
x
Reference in New Issue
Block a user