SDKs · Flutter
Step 2 — Map & search
Show the basemap and add the place-search widget.
Show a map
Give the map a key through UbHubMapOptions and a size. Keep the options stable across rebuilds (hold them in state).
import 'package:ubhub_maps/ubhub_maps.dart';
UbHubMap(
options: UbHubMapOptions(apiKey: apiKey),
height: 480, // or wrap in Expanded; the native map has no intrinsic size
);Add place search
You own the UbHubGeo client: reuse it and close() it in dispose(). The widget returns a typed GeocodingFeature.
final client = UbHubGeo(apiKey: apiKey); // close() it in dispose()
UbHubPlaceSearch(
client: client,
onSelected: (place) async {
setState(() => _markers = [UbHubMarker(place.location, label: place.name)]);
await _map?.flyTo(place.location);
},
);
UbHubMap(
options: options,
markers: _markers,
onReady: (controller) => _map = controller,
);