allocate< T extends NativeType> абстрактный метод
Выделяет byteCount байт памяти в нативной куче.
Если задан alignment, выделенная память будет выровнена как минимум по границе alignment байт.
Чтобы выделить число байт, кратное sizeOf<T>(), вызовите аллокатор напрямую как функцию: allocator<T>(count) (подробности см. в разделе AllocatorAlloc.call).
// This allocates two bytes. If you intended two Int32's, this is an // error. allocator.allocate<Int32>(2); // This allocates eight bytes, which is enough space for two Int32's. // However, this is not the idiomatic way. allocator.allocate<Int32>(sizeOf<Int32>() * 2); // The idiomatic way to allocate space for two Int32 is to call the // allocator directly as a function. allocator<Int32>(2);
Выбрасывает ArgumentError, если невозможно удовлетворить требованиям к числу байт или выравниванию.
Реализация
Pointer<T> allocate<T extends NativeType>(int byteCount, {int? alignment});
© 2012 the Dart project authors
Licensed under the BSD 3-Clause "New" or "Revised" License.
https://api.dart.dev/stable/2.19.6/dart-ffi/Allocator/allocate.html