### Configure Installation Prefix and Bundle Directory Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/linux/CMakeLists.txt Sets up the installation prefix and the directory for the relocatable application bundle. ```cmake # === Installation === # By default, "installing" just makes a relocatable bundle in the build # directory. 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() # Start with a clean build bundle directory every time. 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 Application Executable Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/windows/CMakeLists.txt Installs the main application executable to the specified runtime destination. This makes the application available for execution. ```cmake install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) ``` -------------------------------- ### Install Application Target and Files Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/linux/CMakeLists.txt Installs the application executable, ICU data file, Flutter library, and bundled plugin libraries to the specified bundle directories. ```cmake 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) ``` -------------------------------- ### Define Installation Paths for Bundle Data and Libraries Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/windows/CMakeLists.txt Sets the destination directories for installing application data and libraries. These paths are relative to the CMAKE_INSTALL_PREFIX. ```cmake set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") ``` -------------------------------- ### Install Flutter Assets Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/linux/CMakeLists.txt Installs the Flutter assets directory, ensuring it's fully re-copied on each build to avoid stale files. ```cmake # Fully re-copy the assets directory on each build to avoid having stale files # from a previous install. 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 Bundled Plugin Libraries Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/windows/CMakeLists.txt Installs any bundled plugin libraries to the application's library directory. This ensures that all necessary plugin code is available at runtime. ```cmake if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Install Flutter Library Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/windows/CMakeLists.txt Installs the main Flutter library file to the bundle's library directory. This is a core component required for the Flutter engine to run. ```cmake install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Configure Installation Directory for Visual Studio Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/windows/CMakeLists.txt Sets the installation directory to be adjacent to the executable for Visual Studio builds. This allows the application to run directly from the build directory. ```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() ``` -------------------------------- ### Complete Polygon Editor Example Source: https://context7.com/ibrierley/flutter_map_line_editor/llms.txt Implement an editable polygon by setting addClosePathMarker to true. This example includes styled polygons and a reset button for managing the polygon points. ```dart import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map_dragmarker/flutter_map_dragmarker.dart'; import 'package:flutter_map_line_editor/flutter_map_line_editor.dart'; import 'package:latlong2/latlong.dart'; class PolygonEditorPage extends StatefulWidget { const PolygonEditorPage({super.key}); @override State createState() => _PolygonEditorPageState(); } class _PolygonEditorPageState extends State { late PolyEditor polyEditor; final polyPoints = []; @override void initState() { super.initState(); polyEditor = PolyEditor( // Enable closed path for polygons addClosePathMarker: true, points: polyPoints, pointIcon: const Icon(Icons.crop_square, size: 23), intermediateIcon: const Icon(Icons.lens, size: 15, color: Colors.grey), callbackRefresh: (LatLng? _) => setState(() {}), ); } @override Widget build(BuildContext context) { final testPolygon = Polygon( label: 'My Area', color: Colors.deepOrange.withOpacity(0.3), borderColor: Colors.red, borderStrokeWidth: 4, points: polyPoints, ); return Scaffold( appBar: AppBar(title: const Text('Polygon Editor')), body: FlutterMap( options: MapOptions( onTap: (_, ll) { polyEditor.add(testPolygon.points, ll); }, initialCenter: LatLng(45.5231, -122.6765), initialZoom: 10, ), children: [ TileLayer( urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', ), PolygonLayer(polygons: [testPolygon]), DragMarkers(markers: polyEditor.edit()), ], ), floatingActionButton: FloatingActionButton( child: const Icon(Icons.replay), onPressed: () { setState(() { polyPoints.clear(); }); }, ), ); } } ``` -------------------------------- ### Install AOT Library for Release/Profile Builds Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/windows/CMakeLists.txt Installs the Ahead-Of-Time (AOT) compiled library only for 'Profile' and 'Release' configurations. This optimizes runtime performance by using pre-compiled code. ```cmake install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Install Flutter Assets Directory Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/windows/CMakeLists.txt Installs the Flutter assets directory, ensuring it is fully re-copied on each build to prevent stale files. This includes all application assets like images and fonts. ```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/ibrierley/flutter_map_line_editor/blob/master/example/windows/CMakeLists.txt Installs the ICU data file to the application's data directory. This file is necessary for internationalization and localization features. ```cmake install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Set CMake Minimum Version and Project Name Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/windows/CMakeLists.txt Specifies the minimum required CMake version and defines the project name. This is a standard starting point for CMake projects. ```cmake cmake_minimum_required(VERSION 3.14) project(example LANGUAGES CXX) ``` -------------------------------- ### Install AOT Library on Non-Debug Builds Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/linux/CMakeLists.txt This CMake script installs the AOT library only when the build type is not Debug. Ensure the AOT_LIBRARY variable is correctly set. ```cmake if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Embedded Map in ListView Example Source: https://context7.com/ibrierley/flutter_map_line_editor/llms.txt Demonstrates embedding an editable map within a scrollable widget like ListView. The editor functions seamlessly within this context. ```dart import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map_dragmarker/flutter_map_dragmarker.dart'; import 'package:flutter_map_line_editor/flutter_map_line_editor.dart'; import 'package:latlong2/latlong.dart'; class MapInListViewExample extends StatefulWidget { const MapInListViewExample({super.key}); @override State createState() => _MapInListViewExampleState(); } class _MapInListViewExampleState extends State { late PolyEditor polyEditor; final polyPoints = []; @override void initState() { super.initState(); polyEditor = PolyEditor( addClosePathMarker: false, points: polyPoints, pointIcon: const Icon(Icons.crop_square, size: 23), intermediateIcon: const Icon(Icons.lens, size: 15, color: Colors.grey), callbackRefresh: (LatLng? _) => setState(() {}), ); } @override Widget build(BuildContext context) { final testPolyline = Polyline(color: Colors.deepOrange, points: polyPoints); return Scaffold( appBar: AppBar(title: const Text('Map in ListView')), body: ListView.builder( itemCount: 10, itemBuilder: (context, index) { if (index == 2) { return SizedBox( height: 200, child: Card( child: FlutterMap( options: MapOptions( onTap: (_, ll) { polyEditor.add(testPolyline.points, ll); }, initialCenter: LatLng(45.5231, -122.6765), initialZoom: 10, ), children: [ TileLayer( urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', ), PolylineLayer(polylines: [testPolyline]), DragMarkers(markers: polyEditor.edit()), ], ), ), ); } return SizedBox( height: 100, child: Card( child: Center(child: Text("List Item $index")), ), ); }, ), ); } } ``` -------------------------------- ### Remove Point from Polyline Programmatically Source: https://context7.com/ibrierley/flutter_map_line_editor/llms.txt The remove() method deletes a point at a specified index. This example shows programmatic removal of the last point via a FloatingActionButton. Long-pressing a vertex marker also triggers deletion by default. ```dart import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map_dragmarker/flutter_map_dragmarker.dart'; import 'package:flutter_map_line_editor/flutter_map_line_editor.dart'; import 'package:latlong2/latlong.dart'; class RemovePointExample extends StatefulWidget { @override State createState() => _RemovePointExampleState(); } class _RemovePointExampleState extends State { late PolyEditor polyEditor; final polyPoints = [ LatLng(45.5231, -122.6765), LatLng(45.5331, -122.6565), LatLng(45.5131, -122.6365), ]; @override void initState() { super.initState(); polyEditor = PolyEditor( addClosePathMarker: false, points: polyPoints, pointIcon: const Icon(Icons.crop_square, size: 23), intermediateIcon: const Icon(Icons.lens, size: 15, color: Colors.grey), callbackRefresh: (LatLng? _) => setState(() {}), ); } @override Widget build(BuildContext context) { return Scaffold( body: FlutterMap( options: MapOptions( initialCenter: LatLng(45.5231, -122.6765), initialZoom: 10, ), children: [ TileLayer( urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', ), PolylineLayer(polylines: [ Polyline(color: Colors.deepOrange, points: polyPoints), ]), DragMarkers(markers: polyEditor.edit()), ], ), floatingActionButton: FloatingActionButton( child: const Icon(Icons.delete), onPressed: () { // Programmatically remove the last point if (polyPoints.isNotEmpty) { LatLng removedPoint = polyEditor.remove(polyPoints.length - 1); debugPrint('Removed point: $removedPoint'); } }, ), ); } } ``` -------------------------------- ### Configure Cross-Building Sysroot Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/linux/CMakeLists.txt Sets up the sysroot and find root path for cross-building environments. ```cmake # Root filesystem for cross-building. 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() ``` -------------------------------- ### List application C++ wrapper sources Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/windows/flutter/CMakeLists.txt Appends application-specific C++ wrapper source file names to a list and then prepends the wrapper root directory to each. ```cmake list(APPEND CPP_WRAPPER_SOURCES_APP "flutter_engine.cc" "flutter_view_controller.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") ``` -------------------------------- ### Apply Standard Build Settings Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/windows/runner/CMakeLists.txt Applies a standard set of build settings to the application target. This can be customized for specific needs. ```cmake # Apply the standard set of build settings. This can be removed for applications # that need different build settings. apply_standard_settings(${BINARY_NAME}) ``` -------------------------------- ### Link Libraries and Include Directories Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/windows/runner/CMakeLists.txt Specifies the libraries to link against and the directories to search for include files. Application-specific dependencies should be added here. ```cmake # Add dependency libraries and include directories. Add any application-specific # dependencies here. 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}") ``` -------------------------------- ### List core C++ wrapper sources Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/windows/flutter/CMakeLists.txt Appends core C++ wrapper source file names to a list and then prepends the wrapper root directory to each. ```cmake list(APPEND CPP_WRAPPER_SOURCES_CORE "core_implementations.cc" "standard_codec.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") ``` -------------------------------- ### List plugin C++ wrapper sources Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/windows/flutter/CMakeLists.txt Appends plugin-specific C++ wrapper source file names to a list and then prepends the wrapper root directory to each. ```cmake list(APPEND CPP_WRAPPER_SOURCES_PLUGIN "plugin_registrar.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") ``` -------------------------------- ### Initialize PolyEditor Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/README.md Initialize a PolyEditor instance in your initState() method. This editor manages the points for lines or polygons. ```dart var polyEditor = PolyEditor( points: testPolyline.points, pointIcon: Icon(Icons.crop_square, size: 23), intermediateIcon: Icon(Icons.lens, size: 15, color: Colors.grey), callbackRefresh: () => { this.setState(() {})}, addClosePathMarker: false, // set to true if polygon ); ``` -------------------------------- ### Find and Check PkgConfig Modules in CMake Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/linux/flutter/CMakeLists.txt Uses `PkgConfig` to find and check for required system libraries: GTK, GLIB, and GIO. This ensures that the necessary development files for these libraries are available before proceeding with the build. ```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 Runtime Path for Libraries Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/linux/CMakeLists.txt Configures the runtime path to load bundled libraries from the 'lib/' directory relative to the binary. ```cmake # Load bundled libraries from the lib/ directory relative to the binary. set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") ``` -------------------------------- ### Include Generated Plugin Rules Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/linux/CMakeLists.txt Includes the CMake rules for building generated plugins and adding them to the application. ```cmake # Generated plugin build rules, which manage building the plugins and adding # them to the application. include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Include generated configuration Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/windows/flutter/CMakeLists.txt Includes the generated configuration file, which is provided by the Flutter tool. ```cmake include(${EPHEMERAL_DIR}/generated_config.cmake) ``` -------------------------------- ### Enable Unicode Support Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/windows/CMakeLists.txt Adds definitions to enable Unicode support for all projects. This is crucial for handling international characters correctly. ```cmake add_definitions(-DUNICODE -D_UNICODE) ``` -------------------------------- ### Define Application Target Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/linux/CMakeLists.txt Defines the main application executable target, linking necessary libraries and dependencies. ```cmake add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") # Define the application target. To change its name, change BINARY_NAME above, # not the value here, or `flutter run` will no longer work. # # Any new source files that you add to the application should be added here. add_executable(${BINARY_NAME} "main.cc" "my_application.cc" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" ) # Apply the standard set of build settings. This can be removed for applications # that need different build settings. apply_standard_settings(${BINARY_NAME}) # Add dependency libraries. Add any application-specific dependencies here. target_link_libraries(${BINARY_NAME} PRIVATE flutter) target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) # Run the Flutter tool portions of the build. This must not be removed. add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Add Preprocessor Definitions for Version Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/windows/runner/CMakeLists.txt Adds preprocessor definitions to the build configuration to include Flutter version information. ```cmake # Add preprocessor definitions for the build version. 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}") ``` -------------------------------- ### Import Necessary Packages Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/README.md Import flutter_map_dragmarker and flutter_map_line_editor in your Dart file before using them. ```dart import 'package:flutter_map_dragmarker/flutter_map_dragmarker.dart'; import 'package:flutter_map_line_editor/flutter_map_line_editor.dart'; ``` -------------------------------- ### Define project build directory Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/windows/flutter/CMakeLists.txt Sets the project's build directory path, used for outputting build artifacts. ```cmake set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) ``` -------------------------------- ### Include Generated Plugin Build Rules Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/windows/CMakeLists.txt Includes CMake rules for building generated plugins and adding them to the application. This is essential for integrating third-party or platform-specific functionalities. ```cmake include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Configure Profile Build Mode Linker and Compiler Flags Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/windows/CMakeLists.txt Sets linker and compiler flags for the 'Profile' build mode, inheriting settings from the 'Release' mode. This ensures performance-oriented settings are applied during profiling. ```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}") ``` -------------------------------- ### Define Custom Command for Flutter Tool Backend in CMake Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/linux/flutter/CMakeLists.txt Creates a custom command that executes the Flutter tool backend script. This command is designed to run every time due to the `_phony_` output file, ensuring that build artifacts like the Flutter library and headers are generated. It sets up the necessary environment variables and passes build parameters to the script. ```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 ) ``` -------------------------------- ### Define Flutter library path Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/windows/flutter/CMakeLists.txt Sets the path to the Flutter Windows DLL. ```cmake set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") ``` -------------------------------- ### Apply Standard Compilation Settings Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/linux/CMakeLists.txt Defines a function to apply standard compilation features, options, and definitions to a target. ```cmake # Compilation settings that should be applied to most targets. # # Be cautious about adding new options here, as plugins use this function by # default. In most cases, you should add new options to specific targets instead # of modifying this function. 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() ``` -------------------------------- ### Set Minimum CMake Version and Project Name Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/linux/CMakeLists.txt Specifies the minimum required CMake version and sets the project name for the executable. ```cmake cmake_minimum_required(VERSION 3.10) project(runner LANGUAGES CXX) # The name of the executable created for the application. Change this to change # the on-disk name of your application. set(BINARY_NAME "example") # The unique GTK application identifier for this application. See: # https://wiki.gnome.org/HowDoI/ChooseApplicationID set(APPLICATION_ID "com.github.ibrierley.example") ``` -------------------------------- ### List Flutter library headers Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/windows/flutter/CMakeLists.txt Appends Flutter library header file names to a list and then prepends the ephemeral directory path to each. ```cmake 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}/") ``` -------------------------------- ### Set Runtime Output Directory Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/linux/CMakeLists.txt Configures the runtime output directory for the executable to a subdirectory to prevent accidental execution of unbundled copies. ```cmake # Only the install-generated bundle's copy of the executable will launch # correctly, since the resources must in the right relative locations. To avoid # people trying to run the unbundled copy, put it in a subdirectory instead of # the default top-level location. set_target_properties(${BINARY_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" ) ``` -------------------------------- ### Opt-in to Modern CMake Behaviors Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/windows/CMakeLists.txt Explicitly enables modern CMake behaviors to prevent warnings with newer CMake versions. Use this to ensure compatibility and avoid deprecation notices. ```cmake cmake_policy(SET CMP0063 NEW) ``` -------------------------------- ### Apply Standard Compilation Settings Function Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/windows/CMakeLists.txt Defines a reusable function to apply common compilation settings like C++ standard, warning levels, and exception handling. This promotes consistency across targets. ```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() ``` -------------------------------- ### Define Flutter tool backend custom command Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/windows/flutter/CMakeLists.txt Defines a custom command to execute the Flutter tool backend script. This command generates build artifacts like the Flutter library and headers. The PHONY_OUTPUT is used to ensure the command runs every time. ```cmake 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 ) ``` -------------------------------- ### Configure Build Types for Multi-Config Generators Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/windows/CMakeLists.txt Defines the available build configurations (Debug, Profile, Release) when using a multi-configuration CMake generator. This ensures consistent build options across different modes. ```cmake set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" CACHE STRING "" FORCE) ``` -------------------------------- ### Define Executable Target Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/windows/runner/CMakeLists.txt Defines the main executable target for the Windows application, including source files and generated plugin registration. ```cmake cmake_minimum_required(VERSION 3.14) project(runner LANGUAGES CXX) # Define the application target. To change its name, change BINARY_NAME in the # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer # work. # # Any new source files that you add to the application should be added here. 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" ) ``` -------------------------------- ### Include Flutter Managed Directory Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/linux/CMakeLists.txt Adds the Flutter managed directory as a subdirectory for build rules. ```cmake # Flutter library and tool build rules. set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) ``` -------------------------------- ### Define Executable Binary Name Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/windows/CMakeLists.txt Sets the name of the executable file for the application. This can be modified to change the on-disk name. ```cmake set(BINARY_NAME "example") ``` -------------------------------- ### Include Flutter Managed and Runner Subdirectories Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/windows/CMakeLists.txt Includes the Flutter managed code and the application runner's build configurations. This integrates the core Flutter engine and the application's specific build logic. ```cmake set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) add_subdirectory("runner") ``` -------------------------------- ### Find GTK+ 3.0 Package Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/linux/CMakeLists.txt Finds and checks for the GTK+ 3.0 package using PkgConfig, making its imported target available. ```cmake # System-level dependencies. find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) ``` -------------------------------- ### Define List Prepend Function in CMake Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/linux/flutter/CMakeLists.txt Defines a custom CMake function `list_prepend` to prepend a prefix to each element in a list. This is used as a workaround for older CMake versions that lack the `list(TRANSFORM ... PREPEND ...)` command. ```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() ``` -------------------------------- ### Define AOT library path Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/windows/flutter/CMakeLists.txt Sets the path to the Ahead-Of-Time (AOT) compiled library for the application. ```cmake set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) ``` -------------------------------- ### Set ephemeral directory path Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/windows/flutter/CMakeLists.txt Sets the path to the ephemeral directory, which contains generated build artifacts. ```cmake set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") ``` -------------------------------- ### Define static library for Flutter wrapper app Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/windows/flutter/CMakeLists.txt Defines a static library target for the Flutter wrapper application, applying standard settings and linking against the Flutter library. ```cmake 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) ``` -------------------------------- ### Define static library for Flutter wrapper plugin Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/windows/flutter/CMakeLists.txt Defines a static library target for the Flutter wrapper plugin, applying standard settings, setting position-independent code, and linking against the Flutter library. ```cmake 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) ``` -------------------------------- ### Add Dependencies to pubspec.yaml Source: https://context7.com/ibrierley/flutter_map_line_editor/llms.txt Add these dependencies to your pubspec.yaml file to use the flutter_map_line_editor package. ```yaml dependencies: flutter_map_line_editor: ^8.0.0 flutter_map: ^6.0.0 flutter_map_dragmarker: ^8.0.0 latlong2: ^0.9.0 ``` -------------------------------- ### Define Flutter ICU data file path Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/windows/flutter/CMakeLists.txt Sets the path to the Flutter ICU data file, which is necessary for internationalization. ```cmake set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) ``` -------------------------------- ### Add Flutter Assemble Dependency Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/windows/runner/CMakeLists.txt Ensures that the Flutter tool's assembly process is completed before the application target is built. This is a required step. ```cmake # Run the Flutter tool portions of the build. This must not be removed. add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Set Default Build Type Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/linux/CMakeLists.txt Sets the default build type to 'Debug' if not already configured, and restricts it to 'Debug', 'Profile', or 'Release'. ```cmake # Define build configuration options. 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() ``` -------------------------------- ### Add Points to Polyline on Tap Source: https://context7.com/ibrierley/flutter_map_line_editor/llms.txt Use the add() method with the map's onTap callback to allow users to add points by tapping. This modifies the points list in place and triggers a refresh. ```dart import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map_dragmarker/flutter_map_dragmarker.dart'; import 'package:flutter_map_line_editor/flutter_map_line_editor.dart'; import 'package:latlong2/latlong.dart'; class TapToAddPointsExample extends StatefulWidget { @override State createState() => _TapToAddPointsExampleState(); } class _TapToAddPointsExampleState extends State { late PolyEditor polyEditor; final polyPoints = []; @override void initState() { super.initState(); polyEditor = PolyEditor( addClosePathMarker: false, points: polyPoints, pointIcon: const Icon(Icons.crop_square, size: 23), intermediateIcon: const Icon(Icons.lens, size: 15, color: Colors.grey), callbackRefresh: (LatLng? _) => setState(() {}), ); } @override Widget build(BuildContext context) { final testPolyline = Polyline(color: Colors.deepOrange, points: polyPoints); return FlutterMap( options: MapOptions( initialCenter: LatLng(45.5231, -122.6765), initialZoom: 10, // Tap to add new points onTap: (tapPosition, latLng) { // Add the tapped location as a new point polyEditor.add(testPolyline.points, latLng); }, ), children: [ TileLayer( urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', ), PolylineLayer(polylines: [testPolyline]), DragMarkers(markers: polyEditor.edit()), ], ); } } ``` -------------------------------- ### Add flutter_map_line_editor Dependency Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/README.md Add this package as a dependency in your pubspec.yaml file to use its features. ```yaml dependencies: flutter_map_line_editor: ``` -------------------------------- ### Define Flutter interface library Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/windows/flutter/CMakeLists.txt Defines an interface library target for Flutter, specifying include directories and linking against the Flutter library. ```cmake add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") add_dependencies(flutter flutter_assemble) ``` -------------------------------- ### Set Default Build Type if Not Specified Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/windows/CMakeLists.txt Sets the default build type to 'Debug' if neither CMAKE_BUILD_TYPE nor CMAKE_CONFIGURATION_TYPES are set. This ensures a default build mode is always available. ```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() ``` -------------------------------- ### Configure Flutter Library Interface Target in CMake Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/linux/flutter/CMakeLists.txt Defines an INTERFACE library target named `flutter`. It specifies include directories, links against the Flutter shared library, and links against the found PkgConfig modules (GTK, GLIB, GIO). This target is used by other parts of the project to depend on the Flutter library. ```cmake 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) ``` -------------------------------- ### Add Point on Map Tap Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/README.md Use the onTap callback in MapOptions to add a new point to the polyline when the map is tapped. ```dart onTap: (ll) { polyEditor.add(testPolyline.points, ll); }, ``` -------------------------------- ### Integrate PolyEditor with FlutterMap Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/README.md Add the PolylineLayer and DragMarkers to your FlutterMap's children. The DragMarkers are generated by polyEditor.edit(). ```dart FlutterMap( options: MapOptions( onTap: (_, ll) { polyEditor.add(testPolyline.points, ll); }, ), children: [ // ..... PolylineLayer(polylines: polyLines), DragMarkers(markers: polyEditor.edit()), ], ), ``` -------------------------------- ### Create Flutter Assemble Custom Target in CMake Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/linux/flutter/CMakeLists.txt Defines a custom target `flutter_assemble` that depends on the generated Flutter library and its headers. This target ensures that the Flutter library and headers are built before any other targets that depend on them. ```cmake add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ) ``` -------------------------------- ### Generate DragMarkers with PolyEditor.edit() Source: https://context7.com/ibrierley/flutter_map_line_editor/llms.txt Call polyEditor.edit() within your widget's build method to generate the list of DragMarker widgets. These markers are then added to the FlutterMap's DragMarkers layer. ```dart import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map_dragmarker/flutter_map_dragmarker.dart'; import 'package:flutter_map_line_editor/flutter_map_line_editor.dart'; import 'package:latlong2/latlong.dart'; class PolylineEditorWidget extends StatefulWidget { @override State createState() => _PolylineEditorWidgetState(); } class _PolylineEditorWidgetState extends State { late PolyEditor polyEditor; final polyPoints = []; @override void initState() { super.initState(); polyEditor = PolyEditor( addClosePathMarker: false, points: polyPoints, pointIcon: const Icon(Icons.crop_square, size: 23), intermediateIcon: const Icon(Icons.lens, size: 15, color: Colors.grey), callbackRefresh: (LatLng? _) => setState(() {}), ); } @override Widget build(BuildContext context) { final polyLines = [ Polyline(color: Colors.deepOrange, points: polyPoints), ]; return FlutterMap( options: MapOptions( initialCenter: LatLng(45.5231, -122.6765), initialZoom: 10, ), children: [ TileLayer( urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', ), PolylineLayer(polylines: polyLines), // Add DragMarkers layer with markers from edit() DragMarkers(markers: polyEditor.edit()), ], ); } } ``` -------------------------------- ### Define Flutter assemble custom target Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/windows/flutter/CMakeLists.txt Defines a custom target named 'flutter_assemble' that depends on the generated Flutter library, headers, and wrapper sources. This target ensures these components are built before other targets that depend on them. ```cmake add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ${CPP_WRAPPER_SOURCES_APP} ) ``` -------------------------------- ### Disable Colliding Windows Macros Source: https://github.com/ibrierley/flutter_map_line_editor/blob/master/example/windows/runner/CMakeLists.txt Disables Windows-specific macros that might conflict with C++ standard library functions. ```cmake # Disable Windows macros that collide with C++ standard library functions. 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.