addItems method

Future<bool> addItems(
  1. List newItems, {
  2. bool reassemble = false,
  3. bool append = true,
})

Implementation

Future<bool> addItems(List<dynamic> newItems, {bool reassemble = false, bool append = true}) async{
  if(isNullOrEmpty(newItems)) return false;

  if(reassemble == true || widget.skipAnimation == true || itemAnimation == NUIListItemAnimation.NONE){
    if(append != false) {
      items.addAll(newItems);
    }
    else{
      final cloneList = <dynamic>[];
      cloneList.addAll(items);
      items.clear();
      items.addAll(newItems);
      items.addAll(cloneList);
    }
    listKey.currentState?.setState(() {

    });
    sliverListKey.currentState?.setState(() {

    });
  }
  else{
    if(append != false) {
      for (dynamic item in newItems) {
        if(curModel?.paginationLoading == true || curModel?.skeletalLoading == true) break;
        await Future.delayed(animateDuration);
        addItem(item);
      }
    }
    else{
      int position = fixedFirstItem != null ? 1 : 0;
      for(dynamic item in newItems){
        if(curModel?.paginationLoading == true || curModel?.skeletalLoading == true) break;
        await Future.delayed(animateDuration);
        addItemAt(item, position);
        position++;
      }
    }
  }
  return true;
}