createNodeList function

Pointer<mpv_node_list> createNodeList(
  1. List<String> key,
  2. List<Pointer<mpv_node>> values
)

Implementation

Pointer<mpv_node_list> createNodeList(
    List<String> key, List<Pointer<mpv_node>> values) {
  Pointer<mpv_node_list> list = calloc<mpv_node_list>();
  if (key.length != values.length) {
    throw Exception('Key and value length must be equal');
  }
  list.ref.num = key.length;
  list.ref.values = calloc<mpv_node>(key.length);
  for (int i = 0; i < key.length; i++) {
    list.ref.values[i] = values[i].ref;
  }
  list.ref.keys = calloc<Pointer<Char>>(key.length);
  for (int i = 0; i < key.length; i++) {
    list.ref.keys[i] = key[i].toNativeUtf8().cast<Char>();
  }
  return list;
}