tryAllocate static method

SharedBuffer? tryAllocate(
  1. int byteLength
)

Allocates byteLength bytes of shared memory, or returns null where unsupported — the never-throwing counterpart of SharedBuffer.allocate.

Still throws RangeError for a negative byteLength, on every platform, since that is a caller bug rather than a platform limitation.

Implementation

static SharedBuffer? tryAllocate(int byteLength) {
  RangeError.checkNotNegative(byteLength, 'byteLength');
  return impl.tryAllocateSharedBuffer(byteLength);
}