updateState method

void updateState({
  1. required String who,
  2. LinkedHashSet<K>? selectedKeys,
  3. LinkedHashSet<K>? expandedKeys,
  4. List<TListItem<T, K>>? displayItems,
  5. K? activeKey,
  6. TListItem<T, K>? activeItem,
  7. int? activeIndex,
  8. bool clearActive = false,
  9. int? page,
  10. int? itemsPerPage,
  11. int? totalItems,
  12. bool? loading,
  13. bool? fetching,
  14. bool? hasMoreItems,
  15. bool? isCreatingItem,
  16. bool? isEditingItem,
  17. String? search,
  18. TSelectionMode? selectionMode,
  19. TExpansionMode? expansionMode,
  20. TListError? error,
  21. String? currentCursor,
  22. String? nextCursor,
  23. List<String>? cursorHistory,
  24. Map<String, dynamic>? advancedSearch,
  25. Map<String, dynamic>? additional,
})

Implementation

void updateState({
  required String who,
  LinkedHashSet<K>? selectedKeys,
  LinkedHashSet<K>? expandedKeys,
  List<TListItem<T, K>>? displayItems,
  K? activeKey,
  TListItem<T, K>? activeItem,
  int? activeIndex,
  bool clearActive = false,
  int? page,
  int? itemsPerPage,
  int? totalItems,
  bool? loading,
  bool? fetching,
  bool? hasMoreItems,
  bool? isCreatingItem,
  bool? isEditingItem,
  String? search,
  TSelectionMode? selectionMode,
  TExpansionMode? expansionMode,
  TListError? error,
  String? currentCursor,
  String? nextCursor,
  List<String>? cursorHistory,
  Map<String, dynamic>? advancedSearch,
  Map<String, dynamic>? additional,
}) {
  if (_disposed) {
    debugPrint('Controller already disposed.');
    return;
  }

  var effectiveSelectedKeys = selectedKeys ?? value.selectedKeys;
  var effectiveExpandedKeys = expandedKeys ?? value.expandedKeys;
  var effectiveDisplayItems = displayItems ?? value.displayItems;

  if ((selectable || expandable) && (displayItems != null || selectedKeys != null || expandedKeys != null)) {
    effectiveDisplayItems = _preserveStateOptimized(
      items: effectiveDisplayItems,
      selectedKeys: effectiveSelectedKeys,
      expandedKeys: effectiveExpandedKeys,
    );
  }

  final effectiveActiveKey = clearActive ? null : (activeKey ?? value.activeKey);
  final effectiveActiveItem = clearActive ? null : (activeItem ?? value.activeItem);
  final effectiveActiveIndex = clearActive ? -1 : (activeIndex ?? value.activeIndex);

  value = TListState<T, K>(
    displayItems: effectiveDisplayItems,
    selectedKeys: effectiveSelectedKeys,
    expandedKeys: effectiveExpandedKeys,
    activeKey: effectiveActiveKey,
    activeItem: effectiveActiveItem,
    activeIndex: effectiveActiveIndex,
    isCreatingItem: isCreatingItem ?? value.isCreatingItem,
    isEditingItem: isEditingItem ?? value.isEditingItem,
    page: page ?? value.page,
    itemsPerPage: itemsPerPage ?? value.itemsPerPage,
    totalItems: totalItems ?? value.totalItems,
    loading: loading ?? value.loading,
    fetching: fetching ?? value.fetching,
    hasMoreItems: hasMoreItems ?? value.hasMoreItems,
    search: search ?? value.search,
    error: error ?? value.error,
    currentCursor: currentCursor ?? value.currentCursor,
    nextCursor: nextCursor ?? value.nextCursor,
    cursorHistory: cursorHistory ?? value.cursorHistory,
    advancedSearch: advancedSearch ?? value.advancedSearch,
    additional: additional ?? value.additional,
  );

  //debugPrint("$who: $value");
}