IVector<T> constructor

IVector<T>(
  1. Pointer<COMObject> ptr, {
  2. T creator(
    1. Pointer<COMObject>
    )?,
  3. Allocator allocator = calloc,
})

Creates an instance of IVector<T> using the given ptr.

T must be a either a String or a WinRT type. e.g. IHostName, IStorageFile etc.

...
final vector = IVector<String>(ptr);

creator must be specified if the T is a WinRT type. e.g. IHostName.new, IStorageFile.new etc.

...
final allocator = Arena();
final vector =
    IVector<IHostName>(ptr, creator: IHostName.new, allocator: allocator);

It is the caller's responsibility to deallocate the returned pointers from methods like GetAt, GetView and toList when they are finished with it. A FFI Arena may be passed as a custom allocator for ease of memory management.

{@category winrt}

Implementation

IVector(super.ptr, {this.creator, this.allocator = calloc}) {
  // TODO: Need to update this once we add support for types like `int`,
  // `bool`, `double`, `GUID`, `DateTime`, `Point`, `Size` etc.
  if (![String].contains(T) && creator == null) {
    throw ArgumentError(
        '`creator` parameter must be specified for WinRT types!');
  }
}