NeshanLocationPicker class
A location picker widget that wraps NeshanMap with reverse-geocoding and search features.
This widget provides a complete location selection experience by combining:
- Core map display (via NeshanMap)
- Optional reverse geocoding to show addresses
- Optional address search functionality
- Accept location button
Basic Usage
NeshanLocationPicker(
mapKey: 'your-neshan-map-api-key',
mapConfig: NeshanMapConfig(
initialCenter: LatLng(35.6892, 51.3890),
initialZoom: 15.0,
),
onLocationAccepted: (position, address) {
print('Selected: $address at ${position.latitude}, ${position.longitude}');
},
)
With Reverse Geocoding
NeshanLocationPicker(
mapKey: 'your-map-key',
reverseGeocodingApiKey: 'your-geocoding-key', // Enables address display
mapConfig: NeshanMapConfig(
initialCenter: LatLng(35.6892, 51.3890),
initialZoom: 15.0,
),
onLocationAccepted: (position, address) {
print('Selected: $address at ${position.latitude}, ${position.longitude}');
},
)
With Search and Geocoding
NeshanLocationPicker(
mapKey: 'your-map-key',
reverseGeocodingApiKey: 'your-geocoding-key', // Enables address display
searchApiKey: 'your-search-key', // Enables search button
mapConfig: NeshanMapConfig(
initialCenter: LatLng(35.6892, 51.3890),
initialZoom: 15.0,
),
locationPickerConfig: NeshanLocationPickerConfig(
geocodingDebounce: Duration(milliseconds: 500),
searchDebounce: Duration(milliseconds: 400),
),
onLocationAccepted: (position, address) {
print('Selected: $address at ${position.latitude}, ${position.longitude}');
},
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- NeshanLocationPicker
Constructors
-
NeshanLocationPicker({Key? key, required String mapKey, required String reverseGeocodingApiKey, required void onLocationAccepted(LatLng position, String address), NeshanMapConfig? mapConfig, List<
NeshanMarker> markers = const [], NeshanMapController? controller, String? searchApiKey, NeshanLocationPickerConfig? locationPickerConfig, NeshanLocationPickerUiConfig? locationPickerUiConfig, void onLocationChanged(double lat, double lng)?, void onAddressChanged(String address, ReverseGeocodingResponse response)?, void onApiError(NeshanApiError error)?, NeshanErrorCallback? onError, bool enableDebug = false}) -
Creates a Neshan location picker widget.
const
Properties
- controller → NeshanMapController?
-
Optional controller for programmatic map control.
final
- enableDebug → bool
-
Enables verbose debug logging to the console.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- locationPickerConfig → NeshanLocationPickerConfig?
-
Timing configuration (debounce durations).
final
- locationPickerUiConfig → NeshanLocationPickerUiConfig?
-
UI customization for the three overlay widgets.
final
- mapConfig → NeshanMapConfig?
-
Viewport and style configuration for the underlying map.
final
- mapKey → String
-
The Neshan API key required to display the map.
final
-
markers
→ List<
NeshanMarker> -
Static markers to display on the map alongside the centre-pin overlay.
final
- onAddressChanged → void Function(String address, ReverseGeocodingResponse response)?
-
Called when reverse-geocoding returns a new address.
final
- onApiError → void Function(NeshanApiError error)?
-
Called when any Neshan API request fails.
final
- onError → NeshanErrorCallback?
-
Called on general (non-API) errors.
final
- onLocationAccepted → void Function(LatLng position, String address)
-
Called when the user presses the accept button.
final
- onLocationChanged → void Function(double lat, double lng)?
-
Called whenever the map centre changes.
final
- reverseGeocodingApiKey → String
-
API key for Neshan reverse-geocoding.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- searchApiKey → String?
-
API key for Neshan search.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< NeshanLocationPicker> -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited