IKeyValuePair<K, V>.fromRawPointer constructor

IKeyValuePair<K, V>.fromRawPointer(
  1. Pointer<COMObject> ptr, {
  2. V creator(
    1. Pointer<COMObject>
    )?,
  3. V enumCreator(
    1. int
    )?,
})

Creates an instance of IKeyValuePair using the given ptr.

K must be of type Guid, int, Object, String, or WinRTEnum (e.g. PedometerStepKind).

V must be of type Object, String, or WinRT (e.g. IJsonValue, ProductLicense).

creator must be specified if V is a WinRT type.

final keyValuePair =
    IKeyValuePair<String, IJsonValue?>.fromRawPointer(ptr,
        creator: IJsonValue.fromRawPointer);

enumCreator must be specified if V is a WinRTEnum type.

final keyValuePair =
    IKeyValuePair<String, ChatMessageStatus>.fromRawPointer(ptr,
        enumCreator: ChatMessageStatus.from);

Implementation

IKeyValuePair.fromRawPointer(
  super.ptr, {
  V Function(Pointer<COMObject>)? creator,
  V Function(int)? enumCreator,
})  : _creator = creator,
      _enumCreator = enumCreator {
  if (!isSupportedKeyValuePair<K, V>()) {
    throw ArgumentError('Unsupported key-value pair: IKeyValuePair<$K, $V>');
  }

  if (isSubtypeOfInspectable<V>() && creator == null) {
    throw ArgumentError.notNull('creator');
  }

  if (isSubtypeOfWinRTEnum<V>() && enumCreator == null) {
    throw ArgumentError.notNull('enumCreator');
  }
}