### CMake Project Setup and Configuration Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/example/linux/CMakeLists.txt Basic CMake configuration including minimum version, project name, executable name, and application ID. It also sets up modern CMake behaviors and defines installation paths for libraries. ```cmake cmake_minimum_required(VERSION 3.10) project(runner LANGUAGES CXX) set(BINARY_NAME "example") set(APPLICATION_ID "com.m_code.example") cmake_policy(SET CMP0063 NEW) set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") ``` -------------------------------- ### Installation Configuration for Bundled Application Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/example/linux/CMakeLists.txt Configures the installation process for the application, setting the install prefix to a build bundle directory. It also defines paths for data and library files within the bundle. ```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") ``` -------------------------------- ### CMake Installation Rules Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/example/windows/CMakeLists.txt Defines installation rules for the application, setting the installation prefix to the executable's directory, and installing the runtime components, including the executable, ICU data, Flutter library, bundled plugin libraries, and assets. It also handles the installation of the AOT library for non-Debug builds. ```cmake # === Installation === # Support files are copied into place next to the executable, so that it can # run in place. This is done instead of making a separate bundle (as on Linux) # so that building and running from within Visual Studio will work. set(BUILD_BUNDLE_DIR "$") # Make the "install" step default, as it's required to run. 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() # 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 the AOT library on non-Debug builds only. install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Installing Application Target and Data Files Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/example/linux/CMakeLists.txt Installs the application executable, ICU data file, Flutter library, and bundled plugin libraries to their respective destinations within the installation bundle. It ensures these components are placed correctly for runtime execution. ```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) ``` -------------------------------- ### Installing and Copying Assets Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/example/linux/CMakeLists.txt Installs the application's assets directory by first removing any existing assets from the destination to ensure a clean copy. This prevents stale asset files from being included in the build. ```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) ``` -------------------------------- ### MapConfiguration Example Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/README.md Provides an example of how to configure map-related settings such as the tile URL template, initial zoom level, zoom step, minimum and maximum zoom levels, and map language. ```dart MapConfiguration( urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', initZoom: 17.0, stepZoom: 1.0, minZoomLevel: 2.0, maxZoomLevel: 18.4, mapLanguage: 'en', mapAnimationDuration: Duration(milliseconds: 2000), ) ``` -------------------------------- ### MarkerConfiguration Example Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/README.md Details the configuration for the map marker, including the marker icon, its offset, and options for animation and shadow display. ```dart MarkerConfiguration( markerIcon: Icon(Icons.location_pin, color: Colors.blue), markerIconOffset: 50.0, animateMarker: true, showMarkerShadow: true, ) ``` -------------------------------- ### Install AOT Library (Non-Debug Builds) - CMake Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/example/linux/CMakeLists.txt Installs the AOT library for runtime components when the build type is not Debug. This ensures specific libraries are available in the deployment bundle. ```cmake if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### SearchConfiguration Example Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/README.md Demonstrates the configuration options for the search functionality, including whether to show the search bar, the placeholder text, the maximum number of search results, debounce duration, and the icon for search results. ```dart SearchConfiguration( showSearchBar: true, searchBarHintText: 'Search location', maxSearchResults: 5, searchbarDebounceDuration: Duration(milliseconds: 500), searchResultIcon: Icons.location_on, ) ``` -------------------------------- ### Configure Flutter Location Picker Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/README.md This example shows how to initialize the FlutterLocationPicker with various configurations. It includes setting a user agent, and configuring map, search, and control elements for a tailored user experience. ```dart FlutterLocationPicker.withConfiguration( userAgent: 'MyApp/1.0.0 (contact@mycompany.com)', mapConfiguration: MapConfiguration(/*...*/), searchConfiguration: SearchConfiguration(/*...*/), controlsConfiguration: ControlsConfiguration(/*...*/), // ... other configurations ) ``` -------------------------------- ### Cross-Building Setup for Flutter Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/example/linux/CMakeLists.txt Configures CMake for cross-building by setting the sysroot and find root paths based on the Flutter target platform. This ensures correct library and include path resolution. ```cmake 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() ``` -------------------------------- ### Flutter Library Setup (CMake) Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/example/windows/flutter/CMakeLists.txt Configures the Flutter library, including its DLL and header files, for use in the build process. It defines include directories and links against the Flutter library. Dependencies are set to ensure the library is assembled correctly. ```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 Project Setup and Configuration Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/example/windows/CMakeLists.txt Initializes the CMake project, sets the minimum version, project name, and executable binary name. It also enables modern CMake behaviors and defines build configuration options for multi-configuration generators and single-configuration generators. ```cmake cmake_minimum_required(VERSION 3.14) project(example 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") # Explicitly opt in to modern CMake behaviors to avoid warnings with recent # versions of CMake. cmake_policy(SET CMP0063 NEW) # Define build configuration option. 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() ``` -------------------------------- ### ControlsConfiguration Example Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/README.md Shows how to customize the map's control elements, including zoom controls, the 'my location' button, icons for zoom in/out, button elevation, and spacing between control buttons. ```dart ControlsConfiguration( showZoomController: true, showLocationController: true, zoomInIcon: Icons.zoom_in, zoomOutIcon: Icons.zoom_out, locationIcon: Icons.my_location, buttonElevation: 6.0, controlButtonsSpacing: 16.0, ) ``` -------------------------------- ### Configure Background Location Permission Bypass in Podfile Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/README.md Sets the BYPASS_PERMISSION_LOCATION_ALWAYS preprocessor macro in the 'ios/Podfile' to automatically bypass background location permission requirements during pod installation. ```ruby post_install do |installer| installer.pods_project.targets.each do |target| if target.name == "geolocator_apple" target.build_configurations.each do |config| config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', 'BYPASS_PERMISSION_LOCATION_ALWAYS=1'] end end end end ``` -------------------------------- ### Defining the Application Executable Target Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/example/linux/CMakeLists.txt Defines the main executable target for the application, including its source files and generated plugin registrant. It also applies standard build settings and links necessary libraries. ```cmake add_executable(${BINARY_NAME} "main.cc" "my_application.cc" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" ) apply_standard_settings(${BINARY_NAME}) target_link_libraries(${BINARY_NAME} PRIVATE flutter) target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Flutter Integration and System Dependencies Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/example/linux/CMakeLists.txt Integrates Flutter's managed directory and finds system-level dependencies like GTK using PkgConfig. It also defines the application ID as a preprocessor macro. ```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}") ``` -------------------------------- ### Including Generated Plugin CMake Rules Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/example/linux/CMakeLists.txt Includes the CMake rules for generated plugins, which manage the building of plugins and their integration into the application. ```cmake include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Setting Runtime Output Directory Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/example/linux/CMakeLists.txt Configures the runtime output directory for the application executable to a subdirectory within the binary directory. This is done to prevent users from running the unbundled copy, ensuring correct resource loading. ```cmake set_target_properties(${BINARY_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" ) ``` -------------------------------- ### Windows: Geolocator Plugin Compatibility Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/README.md Information regarding the Geolocator plugin's compatibility with Windows, requiring Flutter 2.10 or higher and automatic package addition via pubspec.yaml. ```text Requires Flutter 2.10 or higher. Automatically adds geolocator_windows package when geolocator dependency is added to pubspec.yaml. ``` -------------------------------- ### CMake Flutter and Runner Integration Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/example/windows/CMakeLists.txt Includes the Flutter managed directory and the runner subdirectory to integrate Flutter library and tool build rules with the application build. ```cmake # Flutter library and tool build rules. set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) # Application build; see runner/CMakeLists.txt. add_subdirectory("runner") # Generated plugin build rules, which manage building the plugins and adding # them to the application. include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Migration from v3.x to v4.0: Configuration Classes Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/README.md Compares the old way of configuring the FlutterLocationPicker in v3.x with the recommended approach using configuration classes in v4.0, highlighting the improved structure and readability. ```dart // v3.x (old way) FlutterLocationPicker( userAgent: 'MyApp/1.0', zoomButtonsColor: Colors.white, zoomButtonsBackgroundColor: Colors.blue, searchBarHintText: 'Search...', onPicked: (data) => handlePicked(data), ) // v4.0 (new way - cleaner) FlutterLocationPicker.withConfiguration( userAgent: 'MyApp/1.0', controlsConfiguration: ControlsConfiguration( zoomButtonsColor: Colors.white, zoomButtonsBackgroundColor: Colors.blue, ), searchConfiguration: SearchConfiguration( searchBarHintText: 'Search...', ), onPicked: (data) => handlePicked(data), ) ``` -------------------------------- ### Web: Geolocator Plugin Compatibility Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/README.md Notes for using the Geolocator plugin on the web, requiring Flutter 1.20+ and secure contexts (HTTPS). It lists unsupported methods and provides a link to the Geolocation API documentation. ```text Requires Flutter 1.20 or higher. Available only in secure_contexts (HTTPS). Unsupported methods: getLastKnownPosition, openAppSettings, openLocationSettings, getServiceStatusStream. ``` -------------------------------- ### Flutter Tool Backend Execution (CMake) Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/example/windows/flutter/CMakeLists.txt Configures a custom command to execute the Flutter tool backend. This command is responsible for assembling build artifacts like the Flutter library and C++ wrappers. It uses a phony output to ensure execution on every build. ```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} ) ``` -------------------------------- ### C++ Wrapper for Runner (CMake) Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/example/windows/flutter/CMakeLists.txt Defines a static library for the C++ wrapper used by the Flutter runner application. It includes core implementation sources and application-specific sources. It links against the Flutter library and specifies include directories. ```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) ``` -------------------------------- ### Basic Flutter Location Picker Usage Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/README.md Demonstrates the fundamental implementation of the FlutterLocationPicker widget. It requires a user agent and provides a callback for handling picked location data. ```dart import 'package:location_picker_flutter_map/location_picker_flutter_map.dart'; // Simple usage FlutterLocationPicker( userAgent: 'MyApp/1.0.0 (contact@example.com)', // Required! onPicked: (PickedData pickedData) { print('Location: ${pickedData.latLong}'); print('Address: ${pickedData.address}'); }, ) ``` -------------------------------- ### Applying Standard Compilation Settings Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/example/linux/CMakeLists.txt Defines a CMake function to apply standard compilation settings to a target, including C++14 standard, warning flags, optimization levels, and NDEBUG definition based on the build configuration. ```cmake 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() ``` -------------------------------- ### C++ Wrapper for Plugins (CMake) Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/example/windows/flutter/CMakeLists.txt Defines a static library for the C++ wrapper used by Flutter plugins. It includes core implementation sources and plugin-specific sources. Properties like Position Independent Code and C++ visibility are set, and it links against the Flutter library. ```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) ``` -------------------------------- ### Enable AndroidX and Jetifier in Gradle Properties Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/README.md Adds the necessary properties to 'gradle.properties' to enable AndroidX compatibility and Jetifier for Android projects. ```properties android.useAndroidX=true android.enableJetifier=true ``` -------------------------------- ### CMake Standard Compilation Settings Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/example/windows/CMakeLists.txt Applies standard compilation settings to targets, including C++17 standard, warning level 4, treating warnings as errors, and specific compiler options and definitions for Unicode support and exception handling. ```cmake # Use Unicode for all projects. add_definitions(-DUNICODE -D_UNICODE) # 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_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() ``` -------------------------------- ### Custom Build Command for Flutter Tool Backend (CMake) Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/example/linux/flutter/CMakeLists.txt Defines a custom CMake command to execute the Flutter tool backend script. This command is triggered to build the Flutter library and its headers, using environment variables and build configurations provided by the Flutter tool. ```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} ) ``` -------------------------------- ### Define List Prepend Function (CMake) Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/example/linux/flutter/CMakeLists.txt Defines a CMake function `list_prepend` to add a prefix to each element in a list. This is a workaround for older CMake versions (pre-3.10) 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() ``` -------------------------------- ### Find and Check GTK+ Dependencies (CMake) Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/example/linux/flutter/CMakeLists.txt Uses CMake's `find_package` and `pkg_check_modules` to locate and verify the presence of GTK+ 3.0, GLib, and GIO libraries. These are essential system-level dependencies for Flutter's Linux backend. ```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) ``` -------------------------------- ### CMake Profile Build Mode Settings Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/example/windows/CMakeLists.txt Configures linker and compiler flags for the 'Profile' build mode, ensuring consistency with the 'Release' build mode settings. ```cmake # Define settings for the Profile build mode. 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}") ``` -------------------------------- ### CMake Build Configuration for Flutter App Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/example/windows/runner/CMakeLists.txt This snippet defines the core CMake build settings for a Flutter application targeting Windows. It sets the project name, defines the executable target with its source files, applies standard build settings, disables conflicting Windows macros, links necessary libraries, and adds Flutter build dependencies. ```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" ) # Apply the standard set of build settings. This can be removed for applications # that need different build settings. apply_standard_settings(${BINARY_NAME}) # Disable Windows macros that collide with C++ standard library functions. target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") # Add dependency libraries and include directories. Add any application-specific # dependencies here. target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") # Run the Flutter tool portions of the build. This must not be removed. add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Service Classes for Location, Geocoding, and Permissions Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/README.md Illustrates the usage of independent service classes for performing location operations, geocoding, and handling location permissions. These services can be utilized separately within the application. ```dart // Location operations final locationService = LocationService(); final position = await locationService.getCurrentPosition(); // Geocoding operations final geocodingService = GeocodingService( nominatimHost: 'nominatim.openstreetmap.org', userAgent: 'MyApp/1.0.0', ); final results = await geocodingService.searchLocations('New York'); // Permission handling final permissionService = PermissionService(context); await permissionService.checkAndRequestLocationPermission(); ``` -------------------------------- ### Flutter Project: Add location_picker_flutter_map Dependency Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/README.md Shows how to add the location_picker_flutter_map package as a dependency in a Flutter project's pubspec.yaml file. ```yaml dependencies: location_picker_flutter_map: ^4.1.0 ``` -------------------------------- ### Configure Flutter Library Target (CMake) Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/example/linux/flutter/CMakeLists.txt Configures the Flutter library as an INTERFACE library in CMake. It sets include directories, links against the Flutter shared object and GTK dependencies, and adds a dependency on the `flutter_assemble` target. ```cmake 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) ``` -------------------------------- ### macOS: Info.plist for Location Usage Description Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/README.md Adds the NSLocationUsageDescription key to the Info.plist file for macOS applications to request location access. The string value should be tailored to the app's specific needs. ```xml NSLocationUsageDescription This app needs access to location. ``` -------------------------------- ### Set Compile SDK Version in Android Gradle Build Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/README.md Specifies the compile SDK version in the 'android/app/build.gradle' file, required for AndroidX compatibility. ```gradle android { compileSdkVersion 35 ... } ``` -------------------------------- ### User-Agent Requirement for Nominatim API Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/README.md Illustrates the correct format for the 'userAgent' parameter, which is mandatory for the Nominatim API to avoid 403 errors. Incorrectly formatted or generic user agents will be rejected. ```dart // ✅ Correct format userAgent: 'MyLocationApp/1.2.0 (developer@mycompany.com)' // ❌ These will cause 403 errors userAgent: 'Dart/2.17 (dart:io)' // Generic HTTP library agent userAgent: 'http' // Too generic userAgent: '' // Empty string ``` -------------------------------- ### Advanced Flutter Location Picker Customization Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/README.md Showcases advanced customization options for the FlutterLocationPicker using configuration classes for map, search, controls, marker, and select button. This allows for a highly tailored user experience. ```dart FlutterLocationPicker.withConfiguration( userAgent: 'MyApp/1.0.0 (contact@example.com)', onPicked: (pickedData) => handleLocationPicked(pickedData), // Map Configuration mapConfiguration: MapConfiguration( initZoom: 15.0, stepZoom: 2.0, mapLanguage: 'en', urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', ), // Search Configuration searchConfiguration: SearchConfiguration( maxSearchResults: 8, searchBarHintText: 'Search for places...', searchbarDebounceDuration: Duration(milliseconds: 300), ), // Controls Configuration controlsConfiguration: ControlsConfiguration( zoomInIcon: Icons.add_circle_outline, zoomOutIcon: Icons.remove_circle_outline, locationIcon: Icons.my_location_rounded, zoomButtonsColor: Colors.white, zoomButtonsBackgroundColor: Colors.blue.shade700, buttonElevation: 8.0, buttonShape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12), ), ), // Marker Configuration markerConfiguration: MarkerConfiguration( markerIcon: Icon(Icons.location_pin, color: Colors.red, size: 60), showMarkerShadow: true, animateMarker: true, ), // Select Button Configuration selectButtonConfiguration: SelectButtonConfiguration( selectLocationButtonText: 'Choose This Location', selectLocationButtonStyle: ElevatedButton.styleFrom( backgroundColor: Colors.green, foregroundColor: Colors.white, ), ), ) ``` -------------------------------- ### Bypass Background Location Permission in iOS Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/README.md Configures a preprocessor macro in Xcode build settings to bypass the need for NSLocationAlwaysAndWhenInUseUsageDescription, preventing background location permission requests. ```bash target.build_configurations.each do |config| config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', 'BYPASS_PERMISSION_LOCATION_ALWAYS=1'] end ``` -------------------------------- ### Configure Location Usage Description in iOS Info.plist Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/README.md Adds the NSLocationWhenInUseUsageDescription key to the Info.plist file for iOS applications to request location access when the app is in use. ```xml NSLocationWhenInUseUsageDescription This app needs access to location when open. ``` -------------------------------- ### iOS: Info.plist for Location Usage Descriptions Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/README.md Specifies the descriptions for location data access in the Info.plist file for iOS. NSLocationAlwaysAndWhenInUseUsageDescription is used for iOS 11.0 and later, while NSLocationAlwaysUsageDescription is for versions below iOS 11.0. ```xml NSLocationAlwaysAndWhenInUseUsageDescription Your description here NSLocationAlwaysUsageDescription Your description here ``` -------------------------------- ### macOS: Entitlements for Location Services Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/README.md Declares the application's intent to use location services by adding a specific key to DebugProfile.entitlements and Release.entitlements files for macOS. This adds the app to the system's privacy settings. ```xml com.apple.security.personal-information.location ``` -------------------------------- ### iOS: Info.plist for Temporary Full Accuracy Location Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/README.md Defines a dictionary in Info.plist for temporary precise location access using the requestTemporaryFullAccuracy method. The key within the dictionary must match the purposeKey argument passed to the method. ```xml NSLocationTemporaryUsageDescriptionDictionary YourPurposeKey The example App requires temporary access to the device's precise location. ``` -------------------------------- ### Request Location Permissions in Android Manifest Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/README.md Declares the necessary location permissions in the AndroidManifest.xml file for accessing device location. ```xml ``` ```xml ``` ```xml ``` -------------------------------- ### Apply Custom Map Style with MapTiler URL Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/README.md Demonstrates how to set a custom map tile URL using the urlTemplate parameter in the FlutterLocationPicker widget. This allows for the integration of MapTiler themes. ```dart FlutterLocationPicker( urlTemplate: 'https://api.maptiler.com/maps/hybrid/{z}/{x}/{y}.jpg?key={apikey}', ) ``` -------------------------------- ### Flutter Build Type Configuration Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/example/linux/CMakeLists.txt Sets the default build type for the Flutter project to 'Debug' if not already defined. It also restricts the allowed build types to 'Debug', 'Profile', and 'Release'. ```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() ``` -------------------------------- ### Customize Map Controls in Flutter Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/README.md This code demonstrates how to customize the appearance and behavior of map controls within the location picker. It allows for changing icons, button shapes, elevation, size, and shadow effects for zoom buttons. ```dart ControlsConfiguration( zoomInIcon: Icons.add_circle, // Custom zoom icons zoomOutIcon: Icons.remove_circle, buttonShape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(15), ), // Custom button shapes buttonElevation: 8.0, // Shadow effects zoomButtonsSize: 60.0, // Individual sizing showButtonShadow: true, // Enable/disable shadows ) ``` -------------------------------- ### iOS: UIBackgroundModes for Location Updates (iOS 16+) Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/README.md Configures the Info.plist to include 'location' in UIBackgroundModes, necessary for receiving location updates in the background on iOS 16 and later. ```xml UIBackgroundModes location ``` -------------------------------- ### iOS: Enable Location Updates Capability in Xcode Source: https://github.com/michael-m-aher/location_picker_flutter_map/blob/main/README.md Enables the Background Modes capability for Location Updates in an Xcode project. This is crucial for receiving location updates in the background on iOS. A detailed explanation must be provided to Apple during App Store submission. ```text Project > Signing and Capabilities > "+ Capability" button > Location Updates ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.