fl_place_autocomplete_ios 0.1.0
fl_place_autocomplete_ios: ^0.1.0 copied to clipboard
iOS implementation of fl_place_autocomplete.
fl_place_autocomplete_ios #
The iOS implementation of fl_place_autocomplete,
built on the Places SDK for iOS
(GooglePlaces 11.x, Places API (New) endpoints).
This package is endorsed:
depend on fl_place_autocomplete and it is included automatically.
Setup #
- Swift Package Manager only. There is no CocoaPods podspec. Enable SwiftPM
if your Flutter version does not do so by default:
flutter config --enable-swift-package-manager. - iOS deployment target 16.0 or higher (required by the Places SDK). In Xcode, set Runner > General > Minimum Deployments to 16.0.
- Pass your API key (with Places API (New) enabled) at build time:
--dart-define=GOOGLE_PLACES_API_KEY_IOS=...(or the genericGOOGLE_PLACES_API_KEY, or--dart-define-from-file=env.json). The value is compiled into the app, so restrict the key to your bundle identifier. - Fallback when no define is set:
GMSPlacesAPIKeyinios/Runner/Info.plist:
<key>GMSPlacesAPIKey</key>
<string>YOUR_API_KEY</string>
If neither is set, calls fail with PlaceAutocompleteErrorCode.invalidApiKey.
Platform notes #
- Language: the Places SDK for iOS has no per-request language. Results use
the device/app locale, so
languageCodepassed to predictions or place details is ignored on iOS. - Region code: honored for predictions; the SDK's place details request has no region code, so it is ignored there.
- Unsupported place fields: the SDK does not expose
shortFormattedAddress,primaryType,primaryTypeDisplayNameornationalPhoneNumber; they are alwaysnull.internationalPhoneNumbermaps to the SDK's phone number andgoogleMapsUritogoogleMapsLinks.placeURL. - Photos:
fetchPhotoreturns JPEG bytes (PhotoData.bytes), not a URI. - A key (define or
GMSPlacesAPIKey) is required even if another plugin has already provided a Places API key; without one every call fails withinvalidApiKey.GMSPlacesClient.provideAPIKeyis process-wide: when a key was provided earlier in the process, the SDK keeps that earlier key.
Development #
The session, error-mapping, key-resolution, range and photo-store logic lives in the pure-Swift
FlPlaceAutocompleteCore target. Run its unit tests on macOS from this package
directory with tool/test_core.sh, which runs:
FL_PLACE_AUTOCOMPLETE_CORE_ONLY=1 swift test --package-path ios/fl_place_autocomplete_ios
The environment variable drops the Flutter and Places dependencies (which only exist inside a Flutter iOS build) from the manifest.