IVector<T>.fromRawPointer constructor
IVector<T>.fromRawPointer (})
Creates an instance of IVector using the given ptr and iterableIid.
iterableIid must be the IID of the IIterable<T> interface (e.g.
IID_IIterable_String).
T must be of type int, String, Uri, WinRT (e.g. IHostName,
IStorageFile) or WinRTEnum (e.g. DeviceClass).
intType must be specified if T is int. Supported types are: Int16,
Int32, Int64, Uint8, Uint16, Uint32, Uint64.
final vector = IVector<int>.fromRawPointer(ptr, intType: Uint64);
creator must be specified if T is a WinRT type.
final vector = IVector<StorageFile>.fromRawPointer(ptr,
creator: StorageFile.fromRawPointer);
enumCreator and intType must be specified if T is a WinRTEnum.
final vector = IVector<DeviceClass>.fromRawPointer(ptr,
enumCreator: DeviceClass.from, intType: Int32);
Implementation
IVector.fromRawPointer(
super.ptr, {
required String iterableIid,
T Function(Pointer<COMObject>)? creator,
T Function(int)? enumCreator,
Type? intType,
}) : _iterableIid = iterableIid,
_creator = creator,
_enumCreator = enumCreator,
_intType = intType {
if (!isSameType<T, int>() &&
!isSameType<T, String>() &&
!isSameType<T, Uri>() &&
!isSubtypeOfInspectable<T>() &&
!isSubtypeOfWinRTEnum<T>()) {
throw ArgumentError.value(T, 'T', 'Unsupported type');
}
if (isSameType<T, int>() && intType == null) {
throw ArgumentError.notNull('intType');
}
if (isSubtypeOfInspectable<T>() && creator == null) {
throw ArgumentError.notNull('creator');
}
if (isSubtypeOfWinRTEnum<T>()) {
if (enumCreator == null) throw ArgumentError.notNull('enumCreator');
if (intType == null) throw ArgumentError.notNull('intType');
}
if (intType != null && !supportedIntTypes.contains(intType)) {
throw ArgumentError.value(intType, 'intType', 'Unsupported type');
}
}