IVectorView<T> constructor
IVectorView<T> (})
Creates an instance of IVectorView<T>
using the given ptr
.
T
must be a either a String
or a WinRT
type. e.g. IHostName
,
IStorageFile
etc.
...
final vectorView = IVectorView<String>(ptr);
creator
must be specified if the T
is a WinRT
type.
e.g. IHostName.new
, IStorageFile.new
etc.
...
final allocator = Arena();
final vectorView = IVectorView<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.
Implementation
IVectorView(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!');
}
}