### CMake Installation Rules for Runtime Components Source: https://github.com/itsarvinddev/map_location_picker/blob/master/example/windows/CMakeLists.txt Configures installation rules for the application's runtime components. This includes setting the installation prefix, defining bundle directories, and installing the main executable, ICU data, Flutter library, bundled plugin libraries, and assets. It ensures assets are re-copied on each build. ```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 Project Setup and Configuration Source: https://github.com/itsarvinddev/map_location_picker/blob/master/example/linux/CMakeLists.txt This snippet outlines the basic CMake project setup, including minimum version, project name, executable name, and application ID. It also configures modern CMake behaviors and library loading paths. ```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) set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") ``` -------------------------------- ### CMake: Installation Rules for Application Bundle Source: https://github.com/itsarvinddev/map_location_picker/blob/master/example/linux/CMakeLists.txt Defines CMake installation rules to create a relocatable application bundle. It cleans the bundle directory, installs the executable, Flutter ICU data, the Flutter library, bundled plugin libraries, and assets. ```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) ``` -------------------------------- ### Update Bottom Card Builder with onNext Callback Source: https://github.com/itsarvinddev/map_location_picker/blob/master/MIGRATION_GUIDE.md Provides an example of the updated `bottomCardBuilder` signature, which now includes an `onNext` callback. This allows for handling the 'select' action directly within the builder. ```dart bottomCardBuilder: (ctx, result, address, isLoading, onNext) { return Button(onPressed: onNext, child: Text("Select")); } ``` -------------------------------- ### Custom Marker Icon Loading in Dart Source: https://github.com/itsarvinddev/map_location_picker/blob/master/MIGRATION_GUIDE.md Provides an example of how to load a custom marker icon from asset files using `BitmapDescriptor.asset` and configuring it within `MapPickerConfig` for the main marker. ```dart void _createMarkerIcon() async { _customMarkerIcon = await BitmapDescriptor.asset( const ImageConfiguration(size: Size(48, 48)), 'assets/marker.webp', ); } MapPickerConfig( mainMarkerIcon: _customMarkerIcon, ) ``` -------------------------------- ### Web API Key Setup Source: https://github.com/itsarvinddev/map_location_picker/blob/master/README.md Shows how to include the Google Maps JavaScript API script in the `web/index.html` file, specifying the API key. ```html ``` -------------------------------- ### Handle Custom Service Instances in Map Location Picker Source: https://github.com/itsarvinddev/map_location_picker/blob/master/MIGRATION_GUIDE.md Shows how to provide custom service instances, like `MyCustomGeoCodingService`, to the MapLocationPicker for advanced use cases. ```dart MapLocationPicker( geoCodingService: MyCustomGeoCodingService(), // Other services... ) ``` -------------------------------- ### Flutter Map Location Picker Example App (Dart) Source: https://github.com/itsarvinddev/map_location_picker/blob/master/README.md This Dart code demonstrates a full example of using the map_location_picker Flutter package. It sets up a basic Flutter app with a screen that allows users to pick a location on a map. The example includes initializing the picker, handling the selected location and formatted address, displaying a static map preview with a marker, and configuring the picker with different options. It depends on Flutter SDK, map_location_picker package, and flutter/material.dart. ```dart import 'package:example/key.dart'; import 'package:flutter/material.dart'; import 'package:map_location_picker/map_location_picker.dart'; void main() => runApp(const MyApp()); final _themeMode = ValueNotifier(ThemeMode.light); class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return ValueListenableBuilder( valueListenable: _themeMode, builder: (context, themeMode, child) { return MaterialApp( theme: ThemeData.light(), darkTheme: ThemeData.dark(), themeMode: themeMode, home: const LocationPickerScreen(), ); }, ); } } class LocationPickerScreen extends StatefulWidget { const LocationPickerScreen({super.key}); @override State createState() => _LocationPickerScreenState(); } class _LocationPickerScreenState extends State { LatLng? _pickedLocation; String _formattedAddress = "No location selected"; BitmapDescriptor? _customMarkerIcon; @override void initState() { super.initState(); _createMarkerIcon(); } void _createMarkerIcon() async { _customMarkerIcon = await BitmapDescriptor.asset( const ImageConfiguration(size: Size(48, 48)), 'assets/marker.webp', ); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: const Text('Location Picker')), body: SingleChildScrollView( child: Column( children: [ // Map preview Container( height: 200, child: _pickedLocation == null ? Center(child: Text("Select a location")) : Image.network( googleStaticMapWithMarker( _pickedLocation!.latitude, _pickedLocation!.longitude, 16, apiKey: YOUR_API_KEY, ), fit: BoxFit.cover, ), ), // Address display ListTile( leading: Icon(Icons.location_on), title: Text(_formattedAddress), ), // Picker options _buildOptionCard( icon: Icons.map, title: "Standard Picker", onTap: () => _openPicker(standardConfig), ), // More options... ], ), ), ); } void _openPicker(MapPickerConfig config) async { await Navigator.push( context, MaterialPageRoute( builder: (context) => MapLocationPicker( config: config.copyWith( initialPosition: _pickedLocation, onNext: (result) { if (result != null) { setState(() { _pickedLocation = LatLng( result.geometry.location.lat, result.geometry.location.lng, ); _formattedAddress = result.formattedAddress ?? ""; }); } }, ), searchConfig: PlacesAutocompleteConfig( apiKey: YOUR_API_KEY, ), ), ), ); } } ``` -------------------------------- ### File Structure for Map Location Picker 2.0 Source: https://github.com/itsarvinddev/map_location_picker/blob/master/MIGRATION_GUIDE.md Illustrates the new file structure for the Map Location Picker library, separating business logic, UI components, and utilities into a `src` directory. ```dart lib/ ├── src/ │ ├── autocomplete_service.dart // Autocomplete business logic │ ├── autocomplete_view.dart // Cupertino-style search UI │ ├── geocoding_service.dart // Reverse geocoding logic │ ├── map_location_picker.dart // Main picker widget │ ├── debouncer.dart // Debounce utility │ └── logger.dart // Logging utility └── map_location_picker.dart // Main export ``` -------------------------------- ### Conditional AOT Library Installation (CMake) Source: https://github.com/itsarvinddev/map_location_picker/blob/master/example/linux/CMakeLists.txt This code installs a specified AOT library to a destination directory only when the CMake build type is not 'Debug'. It utilizes the 'install' command with a 'COMPONENT Runtime' specification. ```cmake if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Configure Places Autocomplete for Search Source: https://github.com/itsarvinddev/map_location_picker/blob/master/MIGRATION_GUIDE.md Shows the correct way to configure the `PlacesAutocomplete` widget with `PlacesAutocompleteConfig`, including setting the API key and `minCharsForSuggestions`. ```dart PlacesAutocomplete( config: PlacesAutocompleteConfig( apiKey: "YOUR_KEY", minCharsForSuggestions: 2, ), // Not in MapPickerConfig ) ``` -------------------------------- ### iOS API Key Setup Source: https://github.com/itsarvinddev/map_location_picker/blob/master/README.md Provides instructions for setting up the Google Maps API key for iOS applications by calling GMSServices.provideAPIKey in AppDelegate.swift. ```swift GMSServices.provideAPIKey("YOUR_IOS_API_KEY") ``` -------------------------------- ### Flutter Library Setup (CMake) Source: https://github.com/itsarvinddev/map_location_picker/blob/master/example/linux/flutter/CMakeLists.txt Configures the Flutter library for the Linux build. It finds PkgConfig modules for GTK, GLIB, and GIO, defines the path to the Flutter library and ICU data file, and sets up include directories and link libraries for the `flutter` target. ```cmake cmake_minimum_required(VERSION 3.10) set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") # Configuration provided via flutter tool. include(${EPHEMERAL_DIR}/generated_config.cmake) # === Flutter Library === # System-level dependencies. 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) ``` -------------------------------- ### Static Map Preview Generation in Dart Source: https://github.com/itsarvinddev/map_location_picker/blob/master/MIGRATION_GUIDE.md Shows how to generate a static map preview using the `googleStaticMapWithMarker` function, embedding a marker at specified latitude and longitude, suitable for use with `Image.network`. ```dart Image.network( googleStaticMapWithMarker( lat, lng, zoom, apiKey: "YOUR_KEY" ), ) ``` -------------------------------- ### Android API Key Setup Source: https://github.com/itsarvinddev/map_location_picker/blob/master/README.md Shows how to set up the Google Maps API key for Android applications by adding a meta-data tag to the AndroidManifest.xml file. ```xml ``` -------------------------------- ### Web API Key Setup Source: https://github.com/itsarvinddev/map_location_picker/blob/master/README.md Details how to set up the Google Maps API key for web applications by including a script tag in the HTML head section, specifying the API key. ```html ``` -------------------------------- ### Customize Search Decoration with CupertinoBoxDecoration Source: https://github.com/itsarvinddev/map_location_picker/blob/master/MIGRATION_GUIDE.md This snippet demonstrates how to customize the decoration of search input fields using `decorationBuilder` and `CupertinoBoxDecoration` within `PlacesAutocompleteConfig`. ```dart PlacesAutocompleteConfig( decorationBuilder: (context, child) { return CupertinoBoxDecoration(child: child); } ) ``` -------------------------------- ### Update Dependencies for Map Location Picker Source: https://github.com/itsarvinddev/map_location_picker/blob/master/MIGRATION_GUIDE.md This snippet shows how to update the map_location_picker dependency in the pubspec.yaml file to version 2.0.0. ```yaml dependencies: map_location_picker: ^2.0.0 ``` -------------------------------- ### Decoupled Service Architecture in Dart Source: https://github.com/itsarvinddev/map_location_picker/blob/master/MIGRATION_GUIDE.md Illustrates the usage of the decoupled service architecture in Dart for reverse geocoding using `GeoCodingService` and searching autocomplete predictions with `AutoCompleteService`. ```dart // Geocoding Service final geoCodingService = GeoCodingService(apiKey: "..."); final (result, allResults) = await geoCodingService.reverseGeocode(position); // Autocomplete Service final autoCompleteService = AutoCompleteService(); final predictions = await autoCompleteService.search(query: "Paris"); ``` -------------------------------- ### iOS API Key Setup (Swift) Source: https://github.com/itsarvinddev/map_location_picker/blob/master/README.md Provides the Swift code snippet to set the Google Maps API key in the application delegate for iOS. ```swift import UIKit import Flutter import GoogleMaps @UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { override func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { GMSServices.provideAPIKey("YOUR KEY HERE") GeneratedPluginRegistrant.register(with: self) return super.application(application, didFinishLaunchingWithOptions: launchOptions) } } ``` -------------------------------- ### UI Framework Shift: Material to Cupertino Source: https://github.com/itsarvinddev/map_location_picker/blob/master/MIGRATION_GUIDE.md Demonstrates the breaking change from using Material Design's `InputDecoration` to the new Cupertino-style `PlacesAutocomplete` widget, which internally uses `CupertinoTypeAheadField`. ```diff // Old (Material) PlacesAutocomplete( decoration: InputDecoration(...), ) // New (Cupertino) PlacesAutocomplete( // Uses CupertinoTypeAheadField internally ) ``` -------------------------------- ### Customizable Map Controls in Dart Source: https://github.com/itsarvinddev/map_location_picker/blob/master/MIGRATION_GUIDE.md Demonstrates the new approach for customizing map controls within `MapPickerConfig`, allowing for custom `CupertinoButton` widgets for map type and location buttons. ```dart MapPickerConfig( mapTypeButton: CupertinoButton(...), // Fully customizable locationButton: CustomLocationButton(), ) ``` -------------------------------- ### iOS API Key Setup (Objective-C) Source: https://github.com/itsarvinddev/map_location_picker/blob/master/README.md Provides the Objective-C code snippet to set the Google Maps API key in the application delegate for iOS. ```objectivec #include "AppDelegate.h" #include "GeneratedPluginRegistrant.h" #import "GoogleMaps/GoogleMaps.h" @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [GMSServices provideAPIKey:@"YOUR KEY HERE"]; [GeneratedPluginRegistrant registerWithRegistry:self]; return [super application:application didFinishLaunchingWithOptions:launchOptions]; } @end ``` -------------------------------- ### Configure Map Markers in Map Location Picker Source: https://github.com/itsarvinddev/map_location_picker/blob/master/MIGRATION_GUIDE.md This code demonstrates how to configure map markers using `mainMarkerIcon`, `additionalMarkers`, and `customMarkerIcons` within `MapPickerConfig`. ```dart MapPickerConfig( mainMarkerIcon: BitmapDescriptor.defaultMarker, additionalMarkers: { "custom": LatLng(37.422, -122.084), }, customMarkerIcons: { "custom": BitmapDescriptor.defaultMarkerWithHue(120), }, ) ``` -------------------------------- ### Bottom Card Builder Signature Change in Dart Source: https://github.com/itsarvinddev/map_location_picker/blob/master/MIGRATION_GUIDE.md Highlights the signature change for the `bottomCardBuilder` callback, which now includes an `onNext` callback for more interactive bottom card elements, demonstrated with a `CupertinoActionSheet`. ```dart // Old: bottomCardBuilder: (ctx, result, address, isLoading) {...} // New: bottomCardBuilder: (ctx, result, address, isLoading, onNext) { return CupertinoActionSheet( actions: [ CupertinoActionSheetAction( onPressed: onNext, // New callback child: Text(address), ), ], ); } ``` -------------------------------- ### Map Location Picker Configuration in Dart Source: https://github.com/itsarvinddev/map_location_picker/blob/master/MIGRATION_GUIDE.md Shows the new configuration approach for `MapLocationPicker` using `MapPickerConfig` for map-specific settings and `PlacesAutocompleteConfig` for search functionalities. Includes API key, initial position, and custom bottom card builder. ```dart MapLocationPicker( config: MapPickerConfig( apiKey: '...', initialPosition: LatLng(...), // Map-specific parameters bottomCardBuilder: (ctx, result, address, isLoading, onNext) { return CupertinoActionSheet(...); } ), searchConfig: PlacesAutocompleteConfig( apiKey: '...', searchHintText: 'Search locations...', // Autocomplete parameters ), ) ``` -------------------------------- ### Customizable Bottom Sheets with CupertinoActionSheet Source: https://github.com/itsarvinddev/map_location_picker/blob/master/README.md Provides an example of customizing the bottom sheet in MapLocationPicker using a CupertinoActionSheet. This allows for custom actions and displaying additional information. ```dart MapPickerConfig( bottomCardBuilder: (context, result, address, isLoading, onNext) { return CupertinoActionSheet( title: const Text("Selected Location"), actions: [ CupertinoActionSheetAction( onPressed: onNext, child: Text(address), ), ], ); }, ); ``` -------------------------------- ### Automatic Theme Adaptation in Dart Source: https://github.com/itsarvinddev/map_location_picker/blob/master/MIGRATION_GUIDE.md Illustrates how `MapLocationPicker` automatically adapts to the system's light or dark theme. The `ThemeMode` is managed internally, removing the need for manual theme handling in the configuration. ```dart final _themeMode = ValueNotifier(ThemeMode.dark); MapLocationPicker( config: MapPickerConfig(), // Automatically adapts to theme ) ``` -------------------------------- ### Advanced Bottom Sheet Configuration with CupertinoActionSheet Source: https://github.com/itsarvinddev/map_location_picker/blob/master/MIGRATION_GUIDE.md This Dart code snippet configures an advanced bottom sheet using `MapPickerConfig`. It utilizes `CupertinoActionSheet` for the UI, with a `CupertinoActionSheetAction` that triggers the `onNext` callback. ```dart MapPickerConfig( bottomCardBuilder: (ctx, result, address, isLoading, onNext) { return CupertinoActionSheet( title: Text("Confirm Location"), actions: [ CupertinoActionSheetAction( onPressed: onNext, isDefaultAction: true, child: Text(address), ), ], ); }, ) ``` -------------------------------- ### Replace Widget Structures in Map Location Picker Source: https://github.com/itsarvinddev/map_location_picker/blob/master/MIGRATION_GUIDE.md Demonstrates the changes in widget structure when migrating to the new version of MapLocationPicker. The old structure used many direct parameters, while the new structure uses a config object for map and search configurations. ```dart // Old MapLocationPicker( apiKey: "...", currentLatLng: LatLng(...), // 100+ parameters ) // New MapLocationPicker( config: MapPickerConfig( apiKey: "...", initialPosition: LatLng(...), // Map config ), searchConfig: PlacesAutocompleteConfig( apiKey: "...", // Search config ), ) ``` -------------------------------- ### Update Custom Bottom Card Builder in Map Location Picker Source: https://github.com/itsarvinddev/map_location_picker/blob/master/MIGRATION_GUIDE.md Illustrates how to update the `bottomCardBuilder` for custom UI. The new signature includes an `onNext` callback, and the implementation uses `CupertinoActionSheet`. ```dart // Old bottomCardBuilder: (ctx, result, address, isLoading) {...} // New config: MapPickerConfig( bottomCardBuilder: (ctx, result, address, isLoading, onNext) { return CupertinoActionSheet( actions: [ CupertinoActionSheetAction( onPressed: onNext, child: Text(address), ), ], ); } ) ``` -------------------------------- ### CMake Project Configuration Source: https://github.com/itsarvinddev/map_location_picker/blob/master/example/windows/CMakeLists.txt Sets up the basic project configuration, including the minimum required CMake version, project name, and languages. It also defines the executable name for the application. ```cmake cmake_minimum_required(VERSION 3.14) project(example LANGUAGES CXX) set(BINARY_NAME "example") ``` -------------------------------- ### CMake Unicode and Standard Settings Function Source: https://github.com/itsarvinddev/map_location_picker/blob/master/example/windows/CMakeLists.txt Enables Unicode support and defines a function `APPLY_STANDARD_SETTINGS` to apply common compilation features, options, and definitions (like C++17 standard, warning levels, and exceptions handling) to specified targets. ```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: Define Application Executable Target Source: https://github.com/itsarvinddev/map_location_picker/blob/master/example/linux/CMakeLists.txt This snippet defines the main executable target for the application using CMake. It lists the source files, including generated plugin registration, and applies standard build settings. ```cmake add_executable(${BINARY_NAME} "main.cc" "my_application.cc" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" ) apply_standard_settings(${BINARY_NAME}) ``` -------------------------------- ### CMake: Find PkgConfig and GTK Dependency Source: https://github.com/itsarvinddev/map_location_picker/blob/master/example/linux/CMakeLists.txt This CMake code finds the PkgConfig module and checks for the GTK+ 3.0 library, making its imported target available for linking. ```cmake find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") ``` -------------------------------- ### CMake Function for Standard Build Settings Source: https://github.com/itsarvinddev/map_location_picker/blob/master/example/linux/CMakeLists.txt Defines a CMake function `APPLY_STANDARD_SETTINGS` to apply common compilation features, warnings, optimization levels, and definitions to targets. It sets C++14 standard, enables Wall/Werror, and applies optimizations for non-Debug builds. ```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() ``` -------------------------------- ### CMake Flutter and Runner Subdirectory Inclusion Source: https://github.com/itsarvinddev/map_location_picker/blob/master/example/windows/CMakeLists.txt Includes the Flutter managed directory and the 'runner' subdirectory, setting up build rules for Flutter-specific components and the application runner. ```cmake set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) add_subdirectory("runner") ``` -------------------------------- ### CMake: Link Libraries and Add Dependencies Source: https://github.com/itsarvinddev/map_location_picker/blob/master/example/linux/CMakeLists.txt This CMake code links the 'flutter' and 'PkgConfig::GTK' libraries to the application target and adds 'flutter_assemble' as a build dependency. This ensures Flutter resources are built before the application. ```cmake target_link_libraries(${BINARY_NAME} PRIVATE flutter) target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### CMake Profile Build Mode Settings Source: https://github.com/itsarvinddev/map_location_picker/blob/master/example/windows/CMakeLists.txt Defines linker and compiler flags for the 'Profile' build mode, typically by copying settings from the 'Release' build mode. ```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}") ``` -------------------------------- ### Flutter Tool Backend Command (CMake) Source: https://github.com/itsarvinddev/map_location_picker/blob/master/example/linux/flutter/CMakeLists.txt Configures a custom command to run the Flutter tool backend script. This command is designed to execute whenever the build occurs, generating necessary artifacts like the Flutter library and headers. It uses a non-existent file `_phony_` to ensure execution, as direct input/output tracking for the Flutter tool is not yet supported. ```cmake # _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. 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: Set Runtime Output Directory Source: https://github.com/itsarvinddev/map_location_picker/blob/master/example/linux/CMakeLists.txt Configures the runtime output directory for the application target in CMake. This is set to a subdirectory to prevent users from running unbundled executables, ensuring proper resource loading. ```cmake set_target_properties(${BINARY_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" ) ``` -------------------------------- ### Build Flutter C++ Wrapper for Runner in CMake Source: https://github.com/itsarvinddev/map_location_picker/blob/master/example/windows/flutter/CMakeLists.txt This snippet defines a static C++ library target named `flutter_wrapper_app`. It includes core and application-specific wrapper source files, links against the `flutter` library, and sets include directories. ```cmake 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 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) ``` -------------------------------- ### Build Flutter C++ Wrapper for Plugins in CMake Source: https://github.com/itsarvinddev/map_location_picker/blob/master/example/windows/flutter/CMakeLists.txt This snippet defines a static C++ library target named `flutter_wrapper_plugin`. It includes core and plugin-specific wrapper source files, sets properties like position-independent code and C++ visibility, and links against the `flutter` library. ```cmake 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) ``` -------------------------------- ### CMake Generated Plugin Inclusion Source: https://github.com/itsarvinddev/map_location_picker/blob/master/example/windows/CMakeLists.txt Includes generated CMake files for plugins, which manage the building and integration of plugins into the application. ```cmake include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Cross-building Configuration in CMake Source: https://github.com/itsarvinddev/map_location_picker/blob/master/example/linux/CMakeLists.txt This CMake code block handles cross-building scenarios by setting the sysroot and adjusting find root path modes based on the FLUTTER_TARGET_PLATFORM_SYSROOT variable. ```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() ``` -------------------------------- ### Configure C++ Runner Application Build with CMake Source: https://github.com/itsarvinddev/map_location_picker/blob/master/example/windows/runner/CMakeLists.txt This CMake script configures the C++ runner application target. It specifies source files, compilation definitions, link libraries, include directories, and build dependencies. It is designed for Windows and integrates with the Flutter build system. ```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) ``` -------------------------------- ### Configure Flutter Library and Headers in CMake Source: https://github.com/itsarvinddev/map_location_picker/blob/master/example/windows/flutter/CMakeLists.txt This snippet configures the Flutter library by setting its path, including necessary header files, and linking against the Flutter library. It defines the `flutter` target as an interface library. ```cmake 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) ``` -------------------------------- ### Custom Command for Flutter Tool Backend in CMake Source: https://github.com/itsarvinddev/map_location_picker/blob/master/example/windows/flutter/CMakeLists.txt This snippet defines a custom command that executes the Flutter tool backend script. It's designed to run every time due to a phony output file, ensuring Flutter assets and wrappers are generated or updated. ```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 MapLocationPicker Usage Source: https://github.com/itsarvinddev/map_location_picker/blob/master/README.md Demonstrates the basic usage of the `MapLocationPicker` widget in Dart, including API key configuration and initial position. ```dart import 'package:map_location_picker/map_location_picker.dart'; MapLocationPicker( config: MapPickerConfig( apiKey: "YOUR_API_KEY", initialPosition: LatLng(37.7749, -122.4194), ), searchConfig: PlacesAutocompleteConfig( apiKey: "YOUR_API_KEY", searchHintText: "Search locations...", ), ); ``` -------------------------------- ### CMake Build Type Configuration Source: https://github.com/itsarvinddev/map_location_picker/blob/master/example/linux/CMakeLists.txt This snippet configures the build type (Debug, Profile, Release) for the CMake project, ensuring a default of 'Debug' if not explicitly set. It also restricts the allowed values for CMAKE_BUILD_TYPE. ```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() ``` -------------------------------- ### Advanced Marker Configuration with Custom Icons and InfoWindows Source: https://github.com/itsarvinddev/map_location_picker/blob/master/README.md Demonstrates advanced marker configuration, including adding additional markers, assigning custom marker icons, and setting custom InfoWindows for specific markers. ```dart MapPickerConfig( additionalMarkers: const { "landmark1": LatLng(37.422, -122.084), "landmark2": LatLng(37.426, -122.083), }, customMarkerIcons: { "landmark1": BitmapDescriptor.defaultMarkerWithHue(BitmapDescriptor.hueYellow), "landmark2": BitmapDescriptor.defaultMarkerWithHue(BitmapDescriptor.hueBlue), }, customInfoWindows: const { "landmark1": InfoWindow(title: "Golden Gate Bridge"), }, ); ``` -------------------------------- ### CMake Build Configuration Management Source: https://github.com/itsarvinddev/map_location_picker/blob/master/example/windows/CMakeLists.txt Configures build types (Debug, Profile, Release) based on the generator type. For multi-configuration generators, it sets CMAKE_CONFIGURATION_TYPES. For single-configuration generators, it defaults to 'Debug' if not already set. ```cmake get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) if(IS_MULTICONFIG) set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" CACHE STRING "" FORCE) else() if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Flutter build mode" FORCE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Profile" "Release") endif() endif() ``` -------------------------------- ### List Prepend Function (CMake) Source: https://github.com/itsarvinddev/map_location_picker/blob/master/example/linux/flutter/CMakeLists.txt Defines a CMake function `list_prepend` to add a prefix to each element of a list. This is used as a workaround for older CMake versions that do not support `list(TRANSFORM ... PREPEND ...)`. It takes a list name and a prefix as input and modifies the list in the parent scope. ```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() ``` -------------------------------- ### Static Map Previews Source: https://github.com/itsarvinddev/map_location_picker/blob/master/README.md Illustrates how to generate static map previews for selected locations using the googleStaticMapWithMarker function. Requires latitude, longitude, zoom level, and an API key. ```dart Image.network( googleStaticMapWithMarker( _pickedLocation!.latitude, _pickedLocation!.longitude, 18, apiKey: YOUR_API_KEY, ), ); ``` -------------------------------- ### Cupertino-Style PlacesAutocomplete Usage Source: https://github.com/itsarvinddev/map_location_picker/blob/master/README.md Shows how to use the `PlacesAutocomplete` widget with a Cupertino-style UI, suitable for iOS applications. ```dart PlacesAutocomplete( config: PlacesAutocompleteConfig( // Uses CupertinoTypeAheadField internally searchHintText: "Search locations...", ), ); ``` -------------------------------- ### Restricting API Keys for iOS/macOS and Android Source: https://github.com/itsarvinddev/map_location_picker/blob/master/README.md Demonstrates how to set headers for restricting API keys based on the platform (iOS, macOS, Android) by including bundle identifiers and SHA-1 certificates. ```dart Map headers = {}; if (Platform.isIOS || Platform.isMacOS) { headers['X-Ios-Bundle-Identifier'] = 'Your Bundle Identifier'; } if (Platform.isAndroid) { headers['X-Android-Package'] = 'Your Bundle Identifier'; headers['X-Android-Cert'] = 'Your Sha-1'; } MapLocationPicker( geoCodingApiHeaders: headers, ... ) ``` -------------------------------- ### Theme Support with ValueNotifier Source: https://github.com/itsarvinddev/map_location_picker/blob/master/README.md Demonstrates built-in support for light/dark themes using a ValueNotifier. The MapLocationPicker automatically adapts to the current theme. ```dart final _themeMode = ValueNotifier(ThemeMode.light); MapLocationPicker( config: MapPickerConfig( // Automatically adapts to current theme ), ); ``` -------------------------------- ### Enhanced Map Configuration Source: https://github.com/itsarvinddev/map_location_picker/blob/master/README.md Shows how to use MapPickerConfig for granular control over UI elements like map type buttons and custom bottom card builders. This allows for fully customizable buttons and content. ```dart MapPickerConfig( mapTypeButton: CustomMapTypeButton(), // Fully customizable buttons locationButton: CustomLocationButton(), bottomCardBuilder: (ctx, result, address, isLoading, onNext) { return CustomBottomCard(address: address); }, ); ``` -------------------------------- ### Theme-Aware Floating Controls Source: https://github.com/itsarvinddev/map_location_picker/blob/master/README.md Shows how to make floating controls theme-aware by dynamically setting their colors based on the current theme's color scheme. This ensures consistency with the application's theme. ```dart // Automatically adapts to light/dark themes MapLocationPicker( config: MapPickerConfig( floatingControlsColor: Theme.of(context).colorScheme.primary, floatingControlsIconColor: Theme.of(context).colorScheme.onPrimary, ), ); ``` -------------------------------- ### Cupertino-Styled Search Input Source: https://github.com/itsarvinddev/map_location_picker/blob/master/README.md Demonstrates how to implement a Cupertino-styled search bar for location predictions. It uses PlacesAutocomplete with a custom item builder for a CupertinoListTile. ```dart PlacesAutocomplete( config: PlacesAutocompleteConfig( searchHintText: "Search locations...", itemBuilder: (context, prediction) => CupertinoListTile( title: Text(prediction.description ?? ""), subtitle: Text(prediction.secondaryText ?? ""), ), ), ); ``` -------------------------------- ### Advanced Marker Support with Custom Icons Source: https://github.com/itsarvinddev/map_location_picker/blob/master/README.md Explains how to create and use custom marker icons from assets. This involves defining a BitmapDescriptor from an image asset and assigning it to a MapPickerConfig. ```dart void _createMarkerIcon() async { _customMarkerIcon = await BitmapDescriptor.asset( const ImageConfiguration(size: Size(48, 48)), 'assets/marker.webp', ); } MapPickerConfig( mainMarkerIcon: _customMarkerIcon, ); ``` -------------------------------- ### Android Location Permissions Source: https://github.com/itsarvinddev/map_location_picker/blob/master/README.md Declares the necessary hardware features for location services in the `AndroidManifest.xml` for Android 5.0+. ```xml ``` -------------------------------- ### Enable Hybrid Composition for Google Maps on Android Source: https://github.com/itsarvinddev/map_location_picker/blob/master/README.md This Dart code enables the use of Hybrid Composition for rendering the GoogleMap widget on Android, which is necessary for certain platform view integrations. It checks the target platform before applying the setting. ```dart if (defaultTargetPlatform == TargetPlatform.android) { AndroidGoogleMapsFlutter.useAndroidViewSurface = true; } ``` -------------------------------- ### Add Google Maps API Key to AndroidManifest.xml Source: https://github.com/itsarvinddev/map_location_picker/blob/master/README.md This XML snippet demonstrates how to securely insert your Google Maps API key into the AndroidManifest.xml file, enabling map functionality within your Flutter application. ```xml ``` -------------------------------- ### Set Android minSdkVersion in build.gradle Source: https://github.com/itsarvinddev/map_location_picker/blob/master/README.md This code configures the minimum SDK version required for your Android application when using the map_location_picker package. It ensures compatibility with Android SDK 20 or higher. ```groovy android { defaultConfig { minSdkVersion 20 } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.