### CMake Installation Configuration Source: https://github.com/superlistapp/super_sliver_list/blob/main/example/windows/CMakeLists.txt Configures installation rules for the application, including setting the installation prefix, defining directories for data and libraries, and installing the executable, ICU data, Flutter library, plugin libraries, and assets. ```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(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() 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(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### CMake Installation Rules for Application Bundle Source: https://github.com/superlistapp/super_sliver_list/blob/main/example/linux/CMakeLists.txt This section defines the installation rules for creating a relocatable application bundle. It specifies the installation prefix, data directories, library directories, and how to copy the executable, assets, and bundled libraries. ```CMake set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() install(CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) install(FILES "${bundled_library}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endforeach(bundled_library) 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) ``` -------------------------------- ### CMake Project Setup and Configuration Source: https://github.com/superlistapp/super_sliver_list/blob/main/example/linux/CMakeLists.txt This snippet sets up the basic CMake project, defines the minimum required version, names the project, and specifies the primary language as CXX. It also includes configurations for the binary name, application ID, and modern CMake behaviors. ```CMake cmake_minimum_required(VERSION 3.10) project(runner LANGUAGES CXX) set(BINARY_NAME "example") set(APPLICATION_ID "com.example.example") cmake_policy(SET CMP0063 NEW) ``` -------------------------------- ### Install AOT Library (CMake) Source: https://github.com/superlistapp/super_sliver_list/blob/main/example/linux/CMakeLists.txt This CMake script installs the AOT library to the runtime destination directory, but only if the build type is not 'Debug'. This ensures that the library is available for release or other non-debug configurations. ```cmake if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Jumping and Animating to Items with ListController Source: https://github.com/superlistapp/super_sliver_list/blob/main/README.md Shows how to use ListController with SuperListView to programmatically jump or animate to a specific item. It includes examples for both `jumpToItem` and `animateToItem`, demonstrating the use of scrollController and alignment. ```dart class _MyState extends State { final _listController = ListController(); final _scrollController = ScrollController(); @override Widget build(BuildContext context) { return SuperListView.builder( listController: _listController, controller: _scrollController, itemCount: 1000, itemBuilder: (context, index) { return ListTile(title: Text('Item $index')); }, ); } void jumpToItem(int index) { _listController.jumpToItem( index: index, scrollController: _scrollController, alignment: 0.5, ); } void animateToItem(int index) { _listController.animateToItem( index: index, scrollController: _scrollController, alignment: 0.5, // You can provide duration and curve depending on the estimated // distance between currentPosition and the target item position. duration: (estimatedDistance) => Duration(milliseconds: 250), curve: (estimatedDistance) => Curves.easeInOut, ); } } ``` -------------------------------- ### Basic SuperSliverList Usage in CustomScrollView Source: https://github.com/superlistapp/super_sliver_list/blob/main/README.md Illustrates how to integrate SuperSliverList into a Flutter CustomScrollView. This example shows SuperSliverList as a sliver with padding, using SliverChildListDelegate to display a list of Text widgets. ```dart CustomScrollView( slivers: [ SliverPadding( padding: const EdgeInsets.all(20.0), sliver: SuperSliverList( delegate: SliverChildListDelegate( [ const Text("I'm dedicating every day to you"), const Text('Domestic life was never quite my style'), const Text('When you smile, you knock me out, I fall apart'), const Text('And I thought I was so smart'), ], ), ), ), ], ) ``` -------------------------------- ### Load Flutter Entrypoint on Window Load Source: https://github.com/superlistapp/super_sliver_list/blob/main/example/web/index.html This code loads the main Flutter entrypoint script ('main.dart.js') when the window loads, initializing the Flutter engine and running the application. ```JavaScript window.addEventListener('load', function (ev) { _flutter.loader.loadEntrypoint({ serviceWorker: { serviceWorkerVersion: serviceWorkerVersion, }, onEntrypointLoaded: function (engineInitializer) { engineInitializer.initializeEngine().then(function (appRunner) { appRunner.runApp(); }); } }); }); ``` -------------------------------- ### Configure CMake Project and Executable Source: https://github.com/superlistapp/super_sliver_list/blob/main/example/windows/runner/CMakeLists.txt Sets the minimum CMake version and project name, then defines the main executable target with its source files and Windows-specific resources. It also applies standard build settings. ```cmake cmake_minimum_required(VERSION 3.14) project(runner LANGUAGES CXX) 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" ) apply_standard_settings(${BINARY_NAME}) ``` -------------------------------- ### CMake: Find and link GTK, GLIB, GIO dependencies Source: https://github.com/superlistapp/super_sliver_list/blob/main/example/linux/flutter/CMakeLists.txt This section uses PkgConfig to find and check for the required GTK, GLIB, and GIO libraries. It then sets up the necessary include directories and links these libraries to the Flutter interface library. ```cmake find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") # Published to parent scope for install step. set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) list(APPEND FLUTTER_LIBRARY_HEADERS "fl_basic_message_channel.h" "fl_binary_codec.h" "fl_binary_messenger.h" "fl_dart_project.h" "fl_engine.h" "fl_json_message_codec.h" "fl_json_method_codec.h" "fl_message_codec.h" "fl_method_call.h" "fl_method_channel.h" "fl_method_codec.h" "fl_method_response.h" "fl_plugin_registrar.h" "fl_plugin_registry.h" "fl_standard_message_codec.h" "fl_standard_method_codec.h" "fl_string_codec.h" "fl_value.h" "fl_view.h" "flutter_linux.h" ) list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") target_link_libraries(flutter INTERFACE PkgConfig::GTK PkgConfig::GLIB PkgConfig::GIO ) add_dependencies(flutter flutter_assemble) ``` -------------------------------- ### Link Libraries and Include Directories Source: https://github.com/superlistapp/super_sliver_list/blob/main/example/windows/runner/CMakeLists.txt Links the necessary libraries ('flutter', 'flutter_wrapper_app', 'dwmapi.lib') and sets the include directories for the application target. This ensures all dependencies are correctly resolved during the build process. ```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}") ``` -------------------------------- ### CMake Flutter and Runner Integration Source: https://github.com/superlistapp/super_sliver_list/blob/main/example/windows/CMakeLists.txt Includes the Flutter managed directory and the runner subdirectory, and includes generated plugin build rules. ```cmake set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) add_subdirectory("runner") include(flutter/generated_plugins.cmake) ``` -------------------------------- ### CMake Library and Cross-Building Configuration Source: https://github.com/superlistapp/super_sliver_list/blob/main/example/linux/CMakeLists.txt This section configures how libraries are loaded, specifically setting the RPATH to include bundled libraries relative to the binary. It also includes conditional logic for cross-building, setting the sysroot and find root path modes. ```CMake set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") if(FLUTTER_TARGET_PLATFORM_SYSROOT) set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) endif() ``` -------------------------------- ### CMake Build Type and Compilation Settings Source: https://github.com/superlistapp/super_sliver_list/blob/main/example/linux/CMakeLists.txt This snippet defines the build configuration options, defaulting to 'Debug' if not already set. It also includes a function `APPLY_STANDARD_SETTINGS` to apply common compilation features and options like C++14 standard, warnings, and optimization levels. ```CMake 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() function(APPLY_STANDARD_SETTINGS TARGET) target_compile_features(${TARGET} PUBLIC cxx_std_14) target_compile_options(${TARGET} PRIVATE -Wall -Werror) target_compile_options(${TARGET} PRIVATE "<$>:-O3>") target_compile_definitions(${TARGET} PRIVATE "<$>:NDEBUG>") endfunction() ``` -------------------------------- ### CMake Project Configuration Source: https://github.com/superlistapp/super_sliver_list/blob/main/example/windows/CMakeLists.txt Sets the minimum CMake version, project name, and languages. It also defines the binary name for the executable and enforces modern CMake policies. ```cmake cmake_minimum_required(VERSION 3.14) project(example LANGUAGES CXX) set(BINARY_NAME "example") cmake_policy(SET CMP0063 NEW) ``` -------------------------------- ### CMake Executable Definition and Dependencies Source: https://github.com/superlistapp/super_sliver_list/blob/main/example/linux/CMakeLists.txt This snippet defines the main executable target for the application, listing its source files. It applies the standard build settings using the previously defined function and adds necessary dependencies, including the Flutter build output and GTK. ```CMake add_executable(${BINARY_NAME} "main.cc" "my_application.cc" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" ) apply_standard_settings(${BINARY_NAME}) add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Flutter Tool Backend Assembly Source: https://github.com/superlistapp/super_sliver_list/blob/main/example/windows/flutter/CMakeLists.txt Defines a custom command to run the Flutter tool backend for assembling build artifacts. It uses a phony output to ensure the command executes on every build and lists all generated files as outputs. ```CMake # === Flutter tool backend === # _phony_ is a non-existent file to force this command to run every time, # since currently there's no way to get a full input/output list from the # flutter tool. set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) add_custom_command( OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ${CPP_WRAPPER_SOURCES_APP} ${PHONY_OUTPUT} COMMAND ${CMAKE_COMMAND} -E env ${FLUTTER_TOOL_ENVIRONMENT} "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" windows-x64 $ VERBATIM ) add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ${CPP_WRAPPER_SOURCES_APP} ) ``` -------------------------------- ### Basic SuperListView Usage Source: https://github.com/superlistapp/super_sliver_list/blob/main/README.md Demonstrates the basic usage of SuperListView, a drop-in replacement for Flutter's ListView. It shows how to create a list with a specified item count and a builder function for each item. ```dart SuperListView.builder( itemCount: 1000, itemBuilder: (context, index) { return ListTile(title: Text('Item $index')); }, ) ``` -------------------------------- ### CMake Flutter Integration and System Dependencies Source: https://github.com/superlistapp/super_sliver_list/blob/main/example/linux/CMakeLists.txt This part of the CMake configuration loads Flutter-managed directories and finds system-level dependencies like GTK using PkgConfig. It defines the application ID as a preprocessor macro and adds the Flutter library. ```CMake set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") target_link_libraries(${BINARY_NAME} PRIVATE flutter) target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) ``` -------------------------------- ### C++ Wrapper for Plugins Source: https://github.com/superlistapp/super_sliver_list/blob/main/example/windows/flutter/CMakeLists.txt Creates a static C++ library for Flutter plugins, including core implementations and plugin registrar sources. It sets up independent code compilation and hidden visibility for the target. ```CMake # === Wrapper === list(APPEND CPP_WRAPPER_SOURCES_CORE "core_implementations.cc" "standard_codec.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") list(APPEND CPP_WRAPPER_SOURCES_PLUGIN "plugin_registrar.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") list(APPEND CPP_WRAPPER_SOURCES_APP "flutter_engine.cc" "flutter_view_controller.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") # Wrapper sources needed for a plugin. add_library(flutter_wrapper_plugin STATIC ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ) apply_standard_settings(flutter_wrapper_plugin) set_target_properties(flutter_wrapper_plugin PROPERTIES POSITION_INDEPENDENT_CODE ON) set_target_properties(flutter_wrapper_plugin PROPERTIES CXX_VISIBILITY_PRESET hidden) target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) target_include_directories(flutter_wrapper_plugin PUBLIC "${WRAPPER_ROOT}/include" ) add_dependencies(flutter_wrapper_plugin flutter_assemble) ``` -------------------------------- ### C++ Wrapper for Runner Source: https://github.com/superlistapp/super_sliver_list/blob/main/example/windows/flutter/CMakeLists.txt Creates a static C++ library for the Flutter runner application, incorporating core implementations and application-specific sources. It links against the Flutter library and includes necessary headers. ```CMake # Wrapper sources needed for the runner. add_library(flutter_wrapper_app STATIC ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_APP} ) apply_standard_settings(flutter_wrapper_app) target_link_libraries(flutter_wrapper_app PUBLIC flutter) target_include_directories(flutter_wrapper_app PUBLIC "${WRAPPER_ROOT}/include" ) add_dependencies(flutter_wrapper_app flutter_assemble) ``` -------------------------------- ### CMake Standard Compilation Settings Source: https://github.com/superlistapp/super_sliver_list/blob/main/example/windows/CMakeLists.txt Defines a function to apply standard compilation settings to targets, including C++ standard version, warning levels, exception handling, and debug definitions. ```cmake add_definitions(-DUNICODE -D_UNICODE) 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() ``` -------------------------------- ### CMake Build Configuration Management Source: https://github.com/superlistapp/super_sliver_list/blob/main/example/windows/CMakeLists.txt Manages build configurations (Debug, Profile, Release) based on whether the generator supports multi-configuration builds. It sets default build types and defines settings for the Profile build mode. ```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() 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}") ``` -------------------------------- ### Flutter Library Configuration Source: https://github.com/superlistapp/super_sliver_list/blob/main/example/windows/flutter/CMakeLists.txt Configures the Flutter library for the project, including setting the library path, headers, and linking the necessary DLL. It also defines the ICU data file and project build directory. ```CMake cmake_minimum_required(VERSION 3.14) set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") # Configuration provided via flutter tool. include(${EPHEMERAL_DIR}/generated_config.cmake) # TODO: Move the rest of this into files in ephemeral. See # https://github.com/flutter/flutter/issues/57146. set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") # === Flutter Library === set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") # Published to parent scope for install step. set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) list(APPEND FLUTTER_LIBRARY_HEADERS "flutter_export.h" "flutter_windows.h" "flutter_messenger.h" "flutter_plugin_registrar.h" "flutter_texture_registrar.h" ) list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") add_dependencies(flutter flutter_assemble) ``` -------------------------------- ### CMake: Custom command for Flutter tool backend Source: https://github.com/superlistapp/super_sliver_list/blob/main/example/linux/flutter/CMakeLists.txt This custom command executes the Flutter tool backend script to generate necessary build artifacts like the Flutter library and headers. It uses environment variables and build type information to configure the command. The `_phony_` target ensures the command runs on every build. ```cmake add_custom_command( OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/_phony_ COMMAND ${CMAKE_COMMAND} -E env ${FLUTTER_TOOL_ENVIRONMENT} "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} VERBATIM ) add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ) ``` -------------------------------- ### CMake Target Properties for Runtime Output Source: https://github.com/superlistapp/super_sliver_list/blob/main/example/linux/CMakeLists.txt This sets the runtime output directory for the executable to a specific intermediate location, preventing users from directly running the unbundled copy. This ensures that the application runs correctly with its associated resources. ```CMake set_target_properties(${BINARY_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" ) ``` -------------------------------- ### Define Flutter Version Preprocessor Definitions Source: https://github.com/superlistapp/super_sliver_list/blob/main/example/windows/runner/CMakeLists.txt Adds preprocessor definitions to the build target to include Flutter version information (full version, major, minor, patch, and build numbers). This allows the application to access version details during compilation. ```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}") ``` -------------------------------- ### CMake: Define list_prepend function Source: https://github.com/superlistapp/super_sliver_list/blob/main/example/linux/flutter/CMakeLists.txt This CMake function prepends a prefix to each element in a given list. It's a custom implementation for older CMake versions (3.10) that lack the built-in list(TRANSFORM ... PREPEND ...) functionality. ```cmake function(list_prepend LIST_NAME PREFIX) set(NEW_LIST "") foreach(element ${${LIST_NAME}}) list(APPEND NEW_LIST "${PREFIX}${element}") endforeach(element) set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) endfunction() ``` -------------------------------- ### Add Flutter Assemble Dependency Source: https://github.com/superlistapp/super_sliver_list/blob/main/example/windows/runner/CMakeLists.txt Ensures that the Flutter assembly process is completed before the application target is built. This is a crucial step for Flutter applications to function correctly. ```cmake add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Optimize Safari WebGL2 and Disable OffscreenCanvas Source: https://github.com/superlistapp/super_sliver_list/blob/main/example/web/index.html This snippet optimizes the Superlist app for Safari by disabling WebGL2.0 for better performance and prevents issues with createImageBitmap and OffscreenCanvas in Flutter web. ```JavaScript var serviceWorkerVersion = null; if ( navigator.userAgent.indexOf("Safari") !== -1 && navigator.userAgent.indexOf("Chrome") === -1 ) { var originalGetContext = HTMLCanvasElement.prototype.getContext; HTMLCanvasElement.prototype.getContext = function () { var contextType = arguments[0]; if (contextType === "webgl2") { return; } return originalGetContext.apply( this, [contextType].concat(Array.prototype.slice.call(arguments, 1)) ); }; } window.createImageBitmap = null; window.OffscreenCanvas = null; ``` -------------------------------- ### Disable Conflicting Windows Macros Source: https://github.com/superlistapp/super_sliver_list/blob/main/example/windows/runner/CMakeLists.txt Disables the NOMINMAX macro to prevent conflicts between Windows-specific macros and C++ standard library functions, ensuring cleaner compilation. ```cmake target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") ``` -------------------------------- ### Improving Extent Estimation with Custom Callback Source: https://github.com/superlistapp/super_sliver_list/blob/main/README.md Demonstrates how to improve the scrollbar behavior of SuperSliverList by providing a custom `estimateExtent` callback. This allows for more accurate estimation of item extents, especially for large lists with variable item sizes. ```dart SuperSliverList( delegate: /*...*/, estimateExtent: (index) => 100.0, // Provide your own extent estimation ) ``` -------------------------------- ### Implement ExtentPrecalculationPolicy in Dart Source: https://github.com/superlistapp/super_sliver_list/blob/main/README.md This snippet shows how to create a custom policy for SuperSliverList to precalculate item extents. The `shouldPrecaculateExtents` method determines when precalculation should occur, in this case, for lists with fewer than 100 items. ```dart class MyPrecalculationPolicy extends ExtentPrecalculationPolicy { @override bool shouldPrecaculateExtents(ExtentPrecalculationContext context) { return context.numberOfItems < 100; } } return SuperSliverList( delegate: /*...*/, extentPrecalculationPolicy: myPolicy, ) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.