### Install Executable Target Source: https://github.com/abdelrahman-atef1/multi_reorderable/blob/main/example/windows/CMakeLists.txt Installs the main executable target to the specified runtime destination. This makes the application runnable after installation. ```cmake install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) ``` -------------------------------- ### Install Flutter Library Source: https://github.com/abdelrahman-atef1/multi_reorderable/blob/main/example/windows/CMakeLists.txt Installs the main Flutter library file to the application's root installation directory. This is a core component required for Flutter applications. ```cmake install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Configure Installation Directory for Executable Source: https://github.com/abdelrahman-atef1/multi_reorderable/blob/main/example/windows/CMakeLists.txt Sets up installation directories and rules for the application's executable and associated files. It ensures files are placed next to the executable for in-place running. ```cmake set(BUILD_BUNDLE_DIR "$") set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") ``` -------------------------------- ### Install Native Assets Source: https://github.com/abdelrahman-atef1/multi_reorderable/blob/main/example/windows/CMakeLists.txt Installs native assets provided by the build process into the application's library directory. This ensures that any platform-specific assets are available at runtime. ```cmake set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install Bundled Plugin Libraries Source: https://github.com/abdelrahman-atef1/multi_reorderable/blob/main/example/windows/CMakeLists.txt Installs any bundled native libraries provided by plugins to the application's library directory. This ensures plugins have their required dependencies. ```cmake if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Custom SelectionBarBuilder Example Source: https://context7.com/abdelrahman-atef1/multi_reorderable/llms.txt Implement a custom selection bar using selectionBarBuilder. This example displays the selected item count and a 'Done' button. ```dart ReorderableMultiDragList( items: myItems, itemBuilder: (ctx, item, i, _, __) => ListTile(title: Text(item)), onReorder: (_, __, r) => setState(() => myItems = r), selectionBarBuilder: (context, selectedCount, onDone) { return Container( padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), color: Colors.indigo.shade50, child: Row( children: [ Icon(Icons.check_circle, color: Colors.indigo, size: 20), const SizedBox(width: 8), Text( '$selectedCount item${selectedCount == 1 ? '' : 's'} selected', style: const TextStyle(fontWeight: FontWeight.w600), ), const Spacer(), TextButton.icon( onPressed: onDone, icon: const Icon(Icons.done), label: const Text('Done'), ), ], ), ); }, ) ``` -------------------------------- ### Custom ItemBuilder Example Source: https://context7.com/abdelrahman-atef1/multi_reorderable/llms.txt Define the appearance of each list item using the itemBuilder callback. This example shows custom styling based on selection and dragging state. ```dart ReorderableMultiDragList( items: ['Alpha', 'Beta', 'Gamma'], itemBuilder: (context, item, index, isSelected, isDragging) { return AnimatedContainer( duration: const Duration(milliseconds: 150), height: 64, padding: const EdgeInsets.symmetric(horizontal: 16), decoration: BoxDecoration( color: isSelected ? Theme.of(context).colorScheme.primaryContainer : Theme.of(context).colorScheme.surface, border: isSelected ? Border.all(color: Theme.of(context).colorScheme.primary, width: 2) : null, ), child: Align( alignment: Alignment.centerLeft, child: Text( item, style: TextStyle( fontWeight: isSelected ? FontWeight.bold : FontWeight.normal, color: isDragging ? Colors.grey : null, ), ), ), ); }, onReorder: (_, __, reordered) => setState(() => myItems = reordered), ) ``` -------------------------------- ### Install AOT Library for Release/Profile Builds Source: https://github.com/abdelrahman-atef1/multi_reorderable/blob/main/example/windows/CMakeLists.txt Installs the Ahead-Of-Time (AOT) compiled library, which improves performance, but only for 'Profile' and 'Release' build configurations. It's placed in the data directory. ```cmake install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Install Flutter Assets Source: https://github.com/abdelrahman-atef1/multi_reorderable/blob/main/example/windows/CMakeLists.txt Installs the Flutter assets directory, which contains UI resources and other assets, into the application's data directory. It ensures assets are removed and re-copied on each build to prevent stale files. ```cmake set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install ICU Data File Source: https://github.com/abdelrahman-atef1/multi_reorderable/blob/main/example/windows/CMakeLists.txt Installs the ICU data file, which is necessary for internationalization and localization, to the data directory of the application bundle. ```cmake install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install Multi Reorderable Package Source: https://github.com/abdelrahman-atef1/multi_reorderable/blob/main/README.md Add the multi_reorderable package to your pubspec.yaml file to include it in your project dependencies. ```yaml dependencies: multi_reorderable: ^0.2.0 ``` -------------------------------- ### onReorder Callback - API Integration Source: https://context7.com/abdelrahman-atef1/multi_reorderable/llms.txt Example of integrating the onReorder callback with a backend API. Updates local UI immediately, then calls an API to persist the changes. ```dart onReorder: (int newIndex, List movedItems, List reorderedItems) { // 1. Update local UI immediately setState(() => myItems = reorderedItems); // 2. Calculate the target item (the item that now follows the moved block) final indexAfterMoved = newIndex + movedItems.length; final targetId = indexAfterMoved < reorderedItems.length ? reorderedItems[indexAfterMoved].id : movedItems.last.id; // moved to end of list // 3. Call your API api.post('/items/sort', { 'ids': movedItems.map((item) => item.id).toList(), // e.g. [307, 306] 'target_id': targetId, // item now after the block }); } ``` -------------------------------- ### Set Minimum CMake Version and Project Name Source: https://github.com/abdelrahman-atef1/multi_reorderable/blob/main/example/windows/CMakeLists.txt Specifies the minimum required CMake version and names the project. This is a standard starting point for any CMake project. ```cmake cmake_minimum_required(VERSION 3.14) project(example LANGUAGES CXX) ``` -------------------------------- ### Import Multi Reorderable Package Source: https://github.com/abdelrahman-atef1/multi_reorderable/blob/main/README.md Import the Multi Reorderable package into your Dart code to start using its widgets and functionalities. ```dart import 'package:multi_reorderable/multi_reorderable.dart'; ``` -------------------------------- ### Configure ReorderableMultiDragList with Custom Theme Source: https://context7.com/abdelrahman-atef1/multi_reorderable/llms.txt Use the `theme` parameter to customize the visual appearance of the list, selection bar, drag handles, and dragged items. This example demonstrates setting various theme properties for a list of strings. ```dart ReorderableMultiDragList( items: myItems, itemBuilder: (context, item, index, isSelected, isDragging) => Text(item), onReorder: (_, __, reordered) => setState(() => myItems = reordered), theme: ReorderableMultiDragTheme( // Item appearance itemColor: Colors.white, selectedItemColor: const Color(0x442196F3), // light blue itemBorderRadius: 12.0, itemHorizontalMargin: 8.0, itemVerticalMargin: 4.0, // Selection bar selectionBarColor: Colors.blue.shade100, // Drop target indicator dropTargetHeight: 4.0, dropTargetColor: Colors.blue, // Drag handle appearance dragHandleIcon: Icons.drag_indicator, dragHandleColor: Colors.grey, dragHandleHoverColor: Colors.blue, dragHandleGrabColor: Colors.green, dragHandleSize: 24.0, // Dragged item visual draggedItemColor: const Color(0x880000FF), draggedItemBorderColor: Colors.blue, draggedItemBorderWidth: 1.0, draggedItemBorderRadius: 8.0, // Checkbox colors selectBoxColor: Colors.blue, selectBoxCheckedColor: Colors.green, selectBoxIconColor: Colors.white, selectBoxIconCheckedColor: Colors.white, selectBoxIconSize: 16.0, // Drag visual style dragStyle: DragStyle.animatedCardStyle, // .stackedStyle | .minimalistStyle // Auto-scroll (theme-level; widget-level params override) autoScrollSpeed: 50.0, autoScrollThreshold: 160.0, pointerThresholdDistance: 10.0, ), ) ``` -------------------------------- ### Custom DragHandleBuilder Example Source: https://context7.com/abdelrahman-atef1/multi_reorderable/llms.txt Customize the drag handle's appearance with the dragHandleBuilder callback. The icon color changes based on the item's selection state. ```dart ReorderableMultiDragList( items: myItems, itemBuilder: (ctx, item, i, _, __) => Text(item), onReorder: (_, __, r) => setState(() => myItems = r), dragHandleBuilder: (context, isSelected) { return Padding( padding: const EdgeInsets.symmetric(horizontal: 4), child: Icon( Icons.drag_indicator, color: isSelected ? Theme.of(context).colorScheme.primary : Colors.grey.shade400, size: 20, ), ); }, ) ``` -------------------------------- ### ReorderableMode Enum Examples Source: https://context7.com/abdelrahman-atef1/multi_reorderable/llms.txt Switch between multi-select drag mode and Flutter's native single-item reorder mode using the ReorderableMode enum. ```dart ReorderableMultiDragList( mode: ReorderableMode.multi, items: items, itemBuilder: (ctx, item, i, isSelected, isDragging) => ListTile(title: Text(item)), onReorder: (newIndex, movedItems, reorderedItems) => setState(() => items = reorderedItems), ) ``` ```dart ReorderableMultiDragList( mode: ReorderableMode.single, items: items, itemBuilder: (ctx, item, i, _, __) => ListTile(title: Text(item)), onReorder: (newIndex, movedItems, reorderedItems) => setState(() => items = reorderedItems), ) ``` -------------------------------- ### DragStyle Enum Examples Source: https://context7.com/abdelrahman-atef1/multi_reorderable/llms.txt Control the visual appearance of dragged items using the DragStyle enum. Choose from stacked, animated card, or minimalist styles. ```dart theme: ReorderableMultiDragTheme(dragStyle: DragStyle.stackedStyle) ``` ```dart theme: ReorderableMultiDragTheme(dragStyle: DragStyle.animatedCardStyle) ``` ```dart theme: ReorderableMultiDragTheme(dragStyle: DragStyle.minimalistStyle) ``` -------------------------------- ### Implement Pagination with ReorderableMultiDragList Source: https://context7.com/abdelrahman-atef1/multi_reorderable/llms.txt Demonstrates setting up ReorderableMultiDragList for paginated data loading. Ensure `currentPage` is externally managed to prevent duplicate loads and that new items are appended. ```dart class PaginatedScreen extends StatefulWidget { const PaginatedScreen({super.key}); @override State createState() => _PaginatedScreenState(); } class _PaginatedScreenState extends State { final listKey = GlobalKey>(); List items = []; int currentPage = 1; final int pageSize = 20; final int totalPages = 10; // 200 items total Future _loadPage(int page, int size) async { // Use the exact `page` argument provided — do NOT hardcode final newItems = await fakeApi(page: page, size: size); // returns List setState(() { items.addAll(newItems); // APPEND, do not replace currentPage = page; // IMPORTANT: sync external page tracker }); } Future _onRefresh() async { setState(() => items.clear()); await _loadPage(1, pageSize); listKey.currentState?.refreshItems(resetPagination: true); } @override Widget build(BuildContext context) { return ReorderableMultiDragList( listKey: listKey, items: items, pageSize: pageSize, currentPage: currentPage, totalPages: totalPages, onPageRequest: _loadPage, enablePullToRefresh: true, onRefresh: _onRefresh, refreshIndicatorColor: Colors.blue, loadingWidgetBuilder: (context) => const Padding( padding: EdgeInsets.all(16), child: Center(child: CircularProgressIndicator.adaptive()), ), noMoreItemsBuilder: (context) => const Padding( padding: EdgeInsets.all(16), child: Center( child: Text( 'All items loaded', style: TextStyle(fontStyle: FontStyle.italic, color: Colors.grey), ), ), ), itemBuilder: (ctx, item, index, isSelected, isDragging) => ListTile(title: Text(item)), onReorder: (_, __, reordered) => setState(() => items = reordered), ); } } ``` -------------------------------- ### Add Dependency Libraries and Include Directories Source: https://github.com/abdelrahman-atef1/multi_reorderable/blob/main/example/windows/runner/CMakeLists.txt Links necessary libraries and specifies include directories for the application target. Application-specific dependencies should be added here. ```cmake target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") ``` -------------------------------- ### Apply Standard Build Settings Source: https://github.com/abdelrahman-atef1/multi_reorderable/blob/main/example/windows/runner/CMakeLists.txt Applies a standard set of build settings to the specified target. This can be customized for applications requiring different build configurations. ```cmake apply_standard_settings(${BINARY_NAME}) ``` -------------------------------- ### Enable Unicode Support Source: https://github.com/abdelrahman-atef1/multi_reorderable/blob/main/example/windows/CMakeLists.txt Adds preprocessor definitions to enable Unicode support for all projects. This is important for handling international characters correctly. ```cmake add_definitions(-DUNICODE -D_UNICODE) ``` -------------------------------- ### Implement Pagination with External Control Source: https://github.com/abdelrahman-atef1/multi_reorderable/blob/main/README.md Enhance the reorderable list with pagination for efficient loading of large datasets. Use a global key for state management and external control over page loading to prevent duplicates. Customize loading and end-of-list indicators. ```dart // Create a global key to access the widget's state final listKey = GlobalKey>(); // Track your current page in your state int currentPage = 1; // In your build method ReorderableMultiDragList( listKey: listKey, items: myItems, pageSize: 20, // Number of items per page currentPage: currentPage, // Pass your current page totalPages: totalPages, // Optional - if you know the total number of pages onPageRequest: (page, pageSize) async { print('Loading page: $page'); // Make your API request with the provided page number final response = await yourApi.fetchItems(page: page, pageSize: pageSize); setState(() { // Add new items to your list (not replace) myItems.addAll(response.items); // IMPORTANT: Update your current page to match the loaded page currentPage = page; }); }, // Customize loading indicator (optional) loadingWidgetBuilder: (context) { return Column( mainAxisSize: MainAxisSize.min, children: [ const CircularProgressIndicator(), const SizedBox(height: 8), const Text('Loading more items...'), ], ); }, // Customize "no more items" message (optional) noMoreItemsBuilder: (context) { return Container( padding: const EdgeInsets.all(16), child: const Text( "You've reached the end of the list", style: TextStyle( fontStyle: FontStyle.italic, color: Colors.grey, ), ), ); }, // ... other properties ) ``` -------------------------------- ### Define Profile Build Mode Settings Source: https://github.com/abdelrahman-atef1/multi_reorderable/blob/main/example/windows/CMakeLists.txt Sets linker and compiler flags for the 'Profile' build mode, copying settings from the 'Release' configuration. This ensures consistent performance tuning. ```cmake set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") ``` -------------------------------- ### Pagination with ReorderableMultiDragList Source: https://context7.com/abdelrahman-atef1/multi_reorderable/llms.txt Demonstrates how to implement pagination in a ReorderableMultiDragList. The widget automatically triggers `onPageRequest` when the user scrolls near the bottom. It's crucial to externally manage `currentPage` to avoid duplicate page loads and to append new items to the existing list. ```APIDOC ## Pagination The widget auto-triggers `onPageRequest` when the user scrolls within 20% of the bottom. The `currentPage` parameter is externally managed to prevent duplicate page loads. Page numbers start at 1. ```dart class PaginatedScreen extends StatefulWidget { const PaginatedScreen({super.key}); @override State createState() => _PaginatedScreenState(); } class _PaginatedScreenState extends State { final listKey = GlobalKey>(); List items = []; int currentPage = 1; final int pageSize = 20; final int totalPages = 10; // 200 items total Future _loadPage(int page, int size) async { // Use the exact `page` argument provided — do NOT hardcode final newItems = await fakeApi(page: page, size: size); // returns List setState(() { items.addAll(newItems); // APPEND, do not replace currentPage = page; // IMPORTANT: sync external page tracker }); } Future _onRefresh() async { setState(() => items.clear()); await _loadPage(1, pageSize); listKey.currentState?.refreshItems(resetPagination: true); } @override Widget build(BuildContext context) { return ReorderableMultiDragList( listKey: listKey, items: items, pageSize: pageSize, currentPage: currentPage, totalPages: totalPages, onPageRequest: _loadPage, enablePullToRefresh: true, onRefresh: _onRefresh, refreshIndicatorColor: Colors.blue, loadingWidgetBuilder: (context) => const Padding( padding: EdgeInsets.all(16), child: Center(child: CircularProgressIndicator.adaptive()), ), noMoreItemsBuilder: (context) => const Padding( padding: EdgeInsets.all(16), child: Center( child: Text( 'All items loaded', style: TextStyle(fontStyle: FontStyle.italic, color: Colors.grey), ), ), ), itemBuilder: (ctx, item, index, isSelected, isDragging) => ListTile(title: Text(item)), onReorder: (_, __, reordered) => setState(() => items = reordered), ); } } ``` ``` -------------------------------- ### Include Generated Plugins Source: https://github.com/abdelrahman-atef1/multi_reorderable/blob/main/example/windows/CMakeLists.txt Includes CMake scripts to manage the building of plugins and their integration into the application. This is crucial for extending application functionality. ```cmake include(flutter/generated_plugins.cmake) ``` -------------------------------- ### DragListItemModel Usage Source: https://context7.com/abdelrahman-atef1/multi_reorderable/llms.txt Demonstrates creating and updating items using DragListItemModel. Equality is based on 'id'. Use copyWith to create modified instances. ```dart final items = [ DragListItemModel( id: 'header', data: 'Section Header', isSelectable: false, isDraggable: false, metadata: {'type': 'header'}, ), DragListItemModel( id: 'item_1', data: 'Row One', metadata: {'priority': 1}, ), DragListItemModel( id: 'item_2', data: 'Row Two', ), ]; // copyWith example final updated = items[1].copyWith( data: 'Row One (edited)', metadata: {'priority': 2}, ); ReorderableMultiDragList>( items: items, itemBuilder: (context, model, index, isSelected, isDragging) { return ListTile( title: Text(model.data), subtitle: Text('id: ${model.id}'); ); }, onReorder: (_, __, reordered) => setState(() => items = reordered), ) ``` -------------------------------- ### Include Flutter Subdirectory Source: https://github.com/abdelrahman-atef1/multi_reorderable/blob/main/example/windows/CMakeLists.txt Includes the Flutter subdirectory, which likely contains Flutter-specific build rules and configurations. This is essential for integrating Flutter into the native build. ```cmake set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) ``` -------------------------------- ### Configure Build Types for Multi-Config Generators Source: https://github.com/abdelrahman-atef1/multi_reorderable/blob/main/example/windows/CMakeLists.txt Sets the available build configurations (Debug, Profile, Release) when using a multi-configuration CMake generator. If not multi-config, it defaults to 'Debug' if not already set. ```cmake get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) if(IS_MULTICONFIG) set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" CACHE STRING "" FORCE) else() if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Flutter build mode" FORCE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Profile" "Release") endif() endif() ``` -------------------------------- ### Include Runner Subdirectory Source: https://github.com/abdelrahman-atef1/multi_reorderable/blob/main/example/windows/CMakeLists.txt Includes the 'runner' subdirectory, which contains the main application's build rules. This is where the primary executable is typically defined. ```cmake add_subdirectory("runner") ``` -------------------------------- ### Add Preprocessor Definitions for Build Version Source: https://github.com/abdelrahman-atef1/multi_reorderable/blob/main/example/windows/runner/CMakeLists.txt Adds preprocessor definitions to the build target to include Flutter version information. This is useful for embedding version details directly into the compiled application. ```cmake target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"" target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}" target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}" target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}" target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") ``` -------------------------------- ### Opt-in to Modern CMake Behaviors Source: https://github.com/abdelrahman-atef1/multi_reorderable/blob/main/example/windows/CMakeLists.txt Explicitly enables modern CMake behaviors to avoid warnings with recent CMake versions. It sets the policy to cover versions from 3.14 up to 3.25. ```cmake cmake_policy(VERSION 3.14...3.25) ``` -------------------------------- ### Define Executable Target Source: https://github.com/abdelrahman-atef1/multi_reorderable/blob/main/example/windows/runner/CMakeLists.txt Defines the main executable target for the Windows runner. Source files for the application should be added here. The BINARY_NAME should be consistent with the top-level CMakeLists.txt for `flutter run` to function correctly. ```cmake add_executable(${BINARY_NAME} WIN32 "flutter_window.cpp" "main.cpp" "utils.cpp" "win32_window.cpp" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" "Runner.rc" "runner.exe.manifest" ) ``` -------------------------------- ### ReorderableMultiDragConfig.setEmptyStateBuilder Source: https://context7.com/abdelrahman-atef1/multi_reorderable/llms.txt Configure a global default builder for the empty state of all `ReorderableMultiDragList` instances. This setting applies app-wide unless a specific widget provides its own `emptyStateBuilder` override. Use `clearEmptyStateBuilder` to remove the global default. ```APIDOC ## ReorderableMultiDragConfig A static configuration class for setting app-wide default builders. Settings here apply to every `ReorderableMultiDragList` instance unless the widget provides its own override. ```dart void main() { // Set once at app startup — all lists will show this empty state by default ReorderableMultiDragConfig.setEmptyStateBuilder((context) { return Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Icon(Icons.inbox_outlined, size: 72, color: Colors.grey.shade300), const SizedBox(height: 16), Text( 'Nothing here yet', style: TextStyle( fontSize: 18, color: Colors.grey.shade500, fontWeight: FontWeight.w500, ), ), ], ), ); }); runApp(const MyApp()); } // To remove the global default later: ReorderableMultiDragConfig.clearEmptyStateBuilder(); ``` ``` -------------------------------- ### Configure Global Default Empty State Builder Source: https://context7.com/abdelrahman-atef1/multi_reorderable/llms.txt Use `ReorderableMultiDragConfig.setEmptyStateBuilder` to set a default UI for empty lists across the application. This can be cleared later using `ReorderableMultiDragConfig.clearEmptyStateBuilder`. ```dart void main() { // Set once at app startup — all lists will show this empty state by default ReorderableMultiDragConfig.setEmptyStateBuilder((context) { return Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Icon(Icons.inbox_outlined, size: 72, color: Colors.grey.shade300), const SizedBox(height: 16), Text( 'Nothing here yet', style: TextStyle( fontSize: 18, color: Colors.grey.shade500, fontWeight: FontWeight.w500, ), ), ], ), ); }); runApp(const MyApp()); } // To remove the global default later: ReorderableMultiDragConfig.clearEmptyStateBuilder(); ``` -------------------------------- ### Define Standard Compilation Settings Function Source: https://github.com/abdelrahman-atef1/multi_reorderable/blob/main/example/windows/CMakeLists.txt A function to apply common compilation settings to targets, including C++ standard, warning levels, and specific compiler options/definitions. Use with caution for plugins. ```cmake function(APPLY_STANDARD_SETTINGS TARGET) target_compile_features(${TARGET} PUBLIC cxx_std_17) target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") target_compile_options(${TARGET} PRIVATE /EHsc) target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") target_compile_definitions(${TARGET} PRIVATE "$:_DEBUG") endfunction() ``` -------------------------------- ### Basic ReorderableMultiDragList Usage Source: https://github.com/abdelrahman-atef1/multi_reorderable/blob/main/README.md Implement a basic reorderable list with multi-selection capabilities. Define items, a custom itemBuilder, and callbacks for reordering and selection changes. ```dart ReorderableMultiDragList( items: ['Item 1', 'Item 2', 'Item 3', 'Item 4', 'Item 5'], itemBuilder: (context, item, index, isSelected, isDragging) { return Container( height: 60, padding: const EdgeInsets.all(8), child: Text( item, style: TextStyle( fontWeight: isSelected ? FontWeight.bold : FontWeight.normal, color: isDragging ? Colors.grey : Colors.black, ), ), ); }, onReorder: (reorderedItems) { setState(() { items = reorderedItems; }); }, onSelectionChanged: (selectedItems) { print('Selected items: $selectedItems'); }, onDone: (selectedItems) { print('Done with selection: $selectedItems'); }, ) ``` -------------------------------- ### DragListUtils - Calculate Stack Rotation Source: https://context7.com/abdelrahman-atef1/multi_reorderable/llms.txt Scales stack rotation based on the number of items. Useful for visual effects in drag-and-drop interfaces. ```dart // calculateStackRotation: scale rotation based on count final rotation = DragListUtils.calculateStackRotation(2, 3.0); // returns 3.0 ``` -------------------------------- ### Set Executable Name Source: https://github.com/abdelrahman-atef1/multi_reorderable/blob/main/example/windows/CMakeLists.txt Defines the name of the executable file for the application. This can be changed to alter the on-disk name of the built application. ```cmake set(BINARY_NAME "example") ``` -------------------------------- ### Define TaskItem model with equality operators Source: https://context7.com/abdelrahman-atef1/multi_reorderable/llms.txt Define a data model for list items. Ensure it overrides `operator ==` and `hashCode` for correct item identification by the widget. ```dart class TaskItem { final String id; final String title; final bool isCompleted; const TaskItem({required this.id, required this.title, this.isCompleted = false}); @override bool operator ==(Object other) => other is TaskItem && other.id == id; @override int get hashCode => id.hashCode; } ``` -------------------------------- ### Enable Pull-to-Refresh Functionality Source: https://github.com/abdelrahman-atef1/multi_reorderable/blob/main/README.md Integrate pull-to-refresh to allow users to refresh the list content by swiping down. Provide an `onRefresh` callback to clear existing items and fetch fresh data, or let the widget use `onPageRequest` for the first page. Customize the refresh indicator's appearance. ```dart ReorderableMultiDragList( // ... other properties enablePullToRefresh: true, // Enable pull-to-refresh onRefresh: () async { // Clear your existing items setState(() { myItems.clear(); }); // Fetch fresh data (first page) final response = await yourApi.fetchItems(page: 1); setState(() { myItems.addAll(response.items); }); }, // Customize refresh indicator (optional) refreshIndicatorColor: Colors.blue, refreshIndicatorBackgroundColor: Colors.white, refreshIndicatorDisplacement: 40.0, ) ``` -------------------------------- ### DragListUtils - Apply Reordering Source: https://context7.com/abdelrahman-atef1/multi_reorderable/llms.txt Manually apply a reorder operation to a list using DragListUtils.applyReordering. This utility can be used for custom reordering logic. ```dart final items = ['A', 'B', 'C', 'D', 'E']; final selected = {'B', 'C'}; final originals = {'B': 1, 'C': 2}; final targets = {'B': 4, 'C': 4}; DragListUtils.applyReordering( items: items, selectedItems: selected, originalPositions: originals, targetPositions: targets, onReorder: (newIndex, movedItems, reorderedItems) { print('New order: $reorderedItems'); // [A, D, E, B, C] print('newIndex: $newIndex'); // 2 print('moved: $movedItems'); // [B, C] }, ); ``` -------------------------------- ### Custom Builders for ReorderableMultiDragList Source: https://github.com/abdelrahman-atef1/multi_reorderable/blob/main/README.md Utilize builder functions for advanced customization of the selection bar and drag handles. This allows for unique UI elements and interactive components within the list. ```dart ReorderableMultiDragList( // ... other properties selectionBarBuilder: (context, selectedCount, onDone) { return Container( padding: const EdgeInsets.all(16), color: Colors.blueGrey.shade100, child: Row( children: [ Text('$selectedCount items selected'), const Spacer(), ElevatedButton( onPressed: onDone, child: const Text('Apply'), ), ], ), ); }, dragHandleBuilder: (context, isSelected) { return Icon( Icons.drag_indicator, color: isSelected ? Colors.blue : Colors.grey, ); }, ) ``` -------------------------------- ### Configure Additional Options for ReorderableMultiDragList Source: https://github.com/abdelrahman-atef1/multi_reorderable/blob/main/README.md Customize the appearance and behavior of the reorderable list with options like done button, selection count, item height, dividers, and animations. Header and footer widgets can also be provided. ```dart ReorderableMultiDragList( // ... other properties showDoneButton: true, doneButtonText: 'Apply', showSelectionCount: true, selectionCountText: '{} selected', itemHeight: 70.0, showDividers: true, dragAnimationDuration: const Duration(milliseconds: 200), reorderAnimationDuration: const Duration(milliseconds: 300), autoScrollSpeed: 15.0, autoScrollThreshold: 100.0, headerWidget: Container( padding: const EdgeInsets.all(16), child: const Text('My Items', style: TextStyle(fontWeight: FontWeight.bold)), ), footerWidget: Container( padding: const EdgeInsets.all(16), child: const Text('Swipe to see more'), ), ) ``` -------------------------------- ### Add Flutter Tool Build Dependency Source: https://github.com/abdelrahman-atef1/multi_reorderable/blob/main/example/windows/runner/CMakeLists.txt Ensures that the Flutter tool's assembly process is completed before the application target is built. This dependency is crucial and must not be removed. ```cmake add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Implement ReorderableMultiDragList in a StatefulWidget Source: https://context7.com/abdelrahman-atef1/multi_reorderable/llms.txt Use ReorderableMultiDragList to create a reorderable list with multi-selection capabilities. Configure item building, reordering logic, and selection callbacks. ```dart class TaskListScreen extends StatefulWidget { const TaskListScreen({super.key}); @override State createState() => _TaskListScreenState(); } class _TaskListScreenState extends State { List tasks = List.generate( 10, (i) => TaskItem(id: 'task_$i', title: 'Task ${i + 1}'), ); List selectedTasks = []; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: const Text('Tasks')), body: ReorderableMultiDragList( items: tasks, itemBuilder: (context, item, index, isSelected, isDragging) { return ListTile( title: Text(item.title), tileColor: isSelected ? Colors.blue.shade50 : null, opacity: isDragging ? 0.3 : 1.0, ); }, onReorder: (newIndex, movedItems, reorderedItems) { setState(() => tasks = reorderedItems); // API call: movedItems are what moved, newIndex is where they landed final indexAfterMoved = newIndex + movedItems.length; final targetId = indexAfterMoved < reorderedItems.length ? reorderedItems[indexAfterMoved].id : movedItems.last.id; print('Moved ${movedItems.map((t) => t.id).toList()} before $targetId'); }, onSelectionChanged: (selected) => setState(() => selectedTasks = selected), onDone: (selected) { ScaffoldMessenger.of(context).showSnackBar( SnackBar(content: Text('${selected.length} tasks selected')), ); }, initialSelection: selectedTasks, showDoneButton: true, doneButtonText: 'Apply', showSelectionCount: true, selectionCountText: '{} selected', itemHeight: 72.0, showDividers: true, dragAnimationDuration: const Duration(milliseconds: 200), reorderAnimationDuration: const Duration(milliseconds: 300), autoScrollSpeed: 15.0, autoScrollThreshold: 100.0, ), ); } } ``` -------------------------------- ### DragListUtils - Calculate Stack Offset Source: https://context7.com/abdelrahman-atef1/multi_reorderable/llms.txt Scales stack offset based on the number of items. Useful for visual effects in drag-and-drop interfaces. ```dart // calculateStackOffset: scale stack offset based on count final offset = DragListUtils.calculateStackOffset(5, 6.0); // returns ~3.6 ``` -------------------------------- ### Reset ReorderableMultiDragList State and Pagination Source: https://context7.com/abdelrahman-atef1/multi_reorderable/llms.txt Call `refreshItems` on the `GlobalKey` to reset internal drag/animation state. Use `resetPagination: true` to also reset the list's pagination tracker and scroll to the top. ```dart final listKey = GlobalKey>(); // Later, e.g. in a FAB callback: void _handleExternalRefresh() async { setState(() => items.clear()); final freshItems = await api.fetchPage(page: 1); setState(() => items.addAll(freshItems)); // Reset widget's internal pagination tracker and scroll to top listKey.currentState?.refreshItems(resetPagination: true); } // Widget declaration: ReorderableMultiDragList( listKey: listKey, items: items, itemBuilder: (ctx, item, i, _, __) => ListTile(title: Text(item.name)), onReorder: (_, __, r) => setState(() => items = r), ) ``` -------------------------------- ### Customize ReorderableMultiDragList Theming Source: https://github.com/abdelrahman-atef1/multi_reorderable/blob/main/README.md Apply a custom theme to the ReorderableMultiDragList to control the appearance of items, selection bar, and dragged elements. This includes colors, border radius, and margins. ```dart ReorderableMultiDragList( // ... other properties theme: ReorderableMultiDragTheme( itemColor: Colors.white, selectedItemColor: Colors.blue.shade50, selectionBarColor: Colors.blue.shade100, draggedItemBorderColor: Colors.blue, itemBorderRadius: 8.0, itemHorizontalMargin: 8.0, itemVerticalMargin: 4.0, maxStackOffset: 6.0, maxStackRotation: 3.0, ), ) ``` -------------------------------- ### Set Drag Style for Multi Reorderable Source: https://github.com/abdelrahman-atef1/multi_reorderable/blob/main/README.md Configure the visual style of dragged items using the `dragStyle` property within `ReorderableMultiDragTheme`. Options include stacked, animated card, and minimalist styles. ```dart ReorderableMultiDragTheme( // Normal theme properties draggedItemBorderColor: Colors.blue, itemBorderRadius: 8.0, // Set the drag style dragStyle: DragStyle.animatedCardStyle, // or .stackedStyle, .minimalistStyle ) ``` -------------------------------- ### Programmatically Refresh the List Source: https://github.com/abdelrahman-atef1/multi_reorderable/blob/main/README.md Control list refreshes programmatically using a GlobalKey. The `refreshItems` method on the widget's state can be called to refresh the list, with an option to reset pagination. ```dart // Refresh the list programmatically void refreshList() { // Reset pagination (optional) listKey.currentState?.refreshItems(resetPagination: true); } // Use in a button or other event FloatingActionButton( onPressed: refreshList, child: Icon(Icons.refresh), ) ``` -------------------------------- ### Add multi_reorderable to pubspec.yaml Source: https://context7.com/abdelrahman-atef1/multi_reorderable/llms.txt Add this dependency to your pubspec.yaml file to include the multi_reorderable package in your Flutter project. ```yaml # pubspec.yaml dependencies: multi_reorderable: ^0.2.2 ``` -------------------------------- ### ReorderableMultiDragListState.refreshItems Source: https://context7.com/abdelrahman-atef1/multi_reorderable/llms.txt The `refreshItems` method, accessible via the widget's `GlobalKey`, allows you to reset the internal drag and animation state of the list. You can optionally reset the pagination state by setting `resetPagination` to `true`, which is useful for full data refreshes. ```APIDOC ## ReorderableMultiDragListState.refreshItems Public method on the widget's state, accessible via `GlobalKey>`. Resets internal drag/animation state and optionally resets pagination. ```dart final listKey = GlobalKey>(); // Later, e.g. in a FAB callback: void _handleExternalRefresh() async { setState(() => items.clear()); final freshItems = await api.fetchPage(page: 1); setState(() => items.addAll(freshItems)); // Reset widget's internal pagination tracker and scroll to top listKey.currentState?.refreshItems(resetPagination: true); } // Widget declaration: ReorderableMultiDragList( listKey: listKey, items: items, itemBuilder: (ctx, item, i, _, __) => ListTile(title: Text(item.name)), onReorder: (_, __, r) => setState(() => items = r), ) ``` ``` -------------------------------- ### Disable Conflicting Windows Macros Source: https://github.com/abdelrahman-atef1/multi_reorderable/blob/main/example/windows/runner/CMakeLists.txt Disables Windows-specific macros that might conflict with C++ standard library functions, preventing potential naming collisions. ```cmake target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.