extract static method
从 origin 的 indexStart 起截取 length 字节。
indexStart 为负按 0 处理;窗口超出尾部按尾部截断;完全越界或
length 非正返回空数组。
Implementation
static Uint8List extract({
required Uint8List origin,
required int indexStart,
required int length,
}) {
if (origin.isEmpty || length <= 0) return Uint8List(0);
final start = indexStart.clamp(0, origin.length);
final end = (start + length).clamp(0, origin.length);
return Uint8List.fromList(origin.sublist(start, end));
}