JList<E>.fromPointer constructor

JList<E>.fromPointer(
  1. Pointer<Void> ptr, {
  2. String clsName = _jListCls,
})

Implementation

JList.fromPointer(Pointer<Void> ptr, {String clsName = _jListCls})
    : super.fromPointer(ptr, clsName) {
  int count = callIntMethodSync('size');
  List temp = List.filled(count, [], growable: false);
  String itemType = '';
  for (var i = 0; i < count; i++) {
    dynamic item = callMethodSync('get', 'Ljava/lang/Object;', args: [i]);
    final convertor = getRegisterPointerConvertor(E.toString());
    if (convertor != null) {
      temp[i] = convertor((item as JObject).pointer);
      continue;
    }
    if (item is String) {
      temp[i] = unBoxingWrapperClass(item, 'java/lang/String');
      continue;
    }
    if (itemType == '') {
      itemType = (item as JObject).className!;
    }
    temp[i] = unBoxingWrapperClass((item as JObject).pointer, itemType);
  }
  raw = temp;
}