FlutterLocationPicker class

Principal widget to show Flutter map using osm api with pick up location marker and search bar. you can track you current location, search for a location and select it. navigate easily in the map to selecte location.

Inheritance

Constructors

FlutterLocationPicker({Key? key, required void onPicked(PickedData pickedData), void onChanged(PickedData pickedData)?, TextStyle selectedLocationButtonTextStyle = const TextStyle(fontSize: 20), void onError(Exception e)?, LatLong? initPosition, double stepZoom = 1, double initZoom = 17, double minZoomLevel = 2, double maxZoomLevel = 18.4, LatLngBounds? maxBounds, String urlTemplate = 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', String mapLanguage = 'en', String nominatimHost = 'nominatim.openstreetmap.org', int? nominatimZoomLevel, Map<String, dynamic>? nominatimAdditionalQueryParameters, String? countryFilter, String selectLocationButtonText = 'Set Current Location', Duration mapAnimationDuration = const Duration(milliseconds: 2000), bool trackMyPosition = false, bool showZoomController = true, bool showLocationController = true, bool showSelectLocationButton = true, bool showCurrentLocationPointer = true, ButtonStyle? selectLocationButtonStyle, double? selectLocationButtonWidth, double? selectLocationButtonHeight, double? selectLocationButtonPositionTop, double? selectLocationButtonPositionRight = 0, double? selectLocationButtonPositionLeft = 0, double? selectLocationButtonPositionBottom = 3, bool showSearchBar = true, Color? searchBarBackgroundColor, Color? searchBarTextColor, String searchBarHintText = 'Search location', Color? searchBarHintColor, OutlineInputBorder? searchbarInputBorder, OutlineInputBorder? searchbarInputFocusBorderp, BorderRadiusGeometry? searchbarBorderRadius, Duration? searchbarDebounceDuration, Color? mapLoadingBackgroundColor, Color? locationButtonBackgroundColor, Color? zoomButtonsBackgroundColor, Color? zoomButtonsColor, Color? locationButtonsColor, Widget? markerIcon, double markerIconOffset = 50.0, bool showContributorBadgeForOSM = false, Color? contributorBadgeForOSMColor, Color contributorBadgeForOSMTextColor = Colors.blue, String contributorBadgeForOSMText = 'OpenStreetMap contributors', double? contributorBadgeForOSMPositionTop, double? contributorBadgeForOSMPositionLeft, double? contributorBadgeForOSMPositionRight = 0, double? contributorBadgeForOSMPositionBottom = -6, List<Widget> mapLayers = const [], Widget? loadingWidget, Widget? selectLocationButtonLeadingIcon})
const

Properties

contributorBadgeForOSMColor Color?
contributorBadgeForOSMColor : (Color) change the color of the badge (default Colors.grey300)
final
contributorBadgeForOSMPositionBottom double?
contributorBadgeForOSMPositionBottom : (double) change the position of the badge from bottom (default -6)
final
contributorBadgeForOSMPositionLeft double?
contributorBadgeForOSMPositionLeft : (double) change the position of the badge from left (default null)
final
contributorBadgeForOSMPositionRight double?
contributorBadgeForOSMPositionRight : (double) change the position of the badge from right (default 0)
final
contributorBadgeForOSMPositionTop double?
final
contributorBadgeForOSMText String
contributorBadgeForOSMText : (String) change the text of the badge (default 'OpenStreetMap contributors')
final
contributorBadgeForOSMTextColor Color
contributorBadgeForOSMTextColor : (Color) change the color of the badge text (default Colors.blue)
final
countryFilter String?
countryFilter : (String) set the list of country codes to filter search results to them (example: 'eg,us') (default = null)
final
hashCode int
The hash code for this object.
no setterinherited
initPosition LatLong?
initPosition :(LatLong?) set the initial location of the pointer on the map
final
initZoom double
initZoom : (double) set initialized zoom in specific location (default = 17)
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
loadingWidget Widget?
loadingWidget : (Widget) show custom widget until the map finish initialization
final
locationButtonBackgroundColor Color?
locationButtonBackgroundColor : (Color) change the background color of the location button
final
locationButtonsColor Color?
locationButtonsColor : (Color) change the color of the location button icon
final
mapAnimationDuration Duration
mapAnimationDuration : (Duration) time duration of the move from point to point animation (default = Duration(milliseconds: 2000))
final
mapLanguage String
mapLanguage : (String) set the language of the map and address text (default = 'en')
final
mapLayers List<Widget>
mapLayers : (List
final
mapLoadingBackgroundColor Color?
mapLoadingBackgroundColor : (Color) change the background color of the loading screen before the map initialized
final
markerIcon Widget?
markerIcon : (IconData) change the marker icon of the map (default = Icon(icons.location_on, color: Colors.blue, size: 50))
final
markerIconOffset double
markerIconOffset : (double) change the marker icon offset in y direction (default = 50.0)
final
maxBounds → LatLngBounds?
maxBounds : (LatLngBounds?) set default max bounds of the map (default = null)
final
maxZoomLevel double
maxZoomLevel : (double) set default zoom value (default = 18.4)
final
minZoomLevel double
minZoomLevel : (double) set default zoom value (default = 2)
final
nominatimAdditionalQueryParameters Map<String, dynamic>?
nominatimAdditionalQueryParameters : (Map<String,dynamic>) additional parameters to add to the nominatim query. Can also be used to override existing parameters (example: {'extratags': '1'}) (default = null)
final
nominatimHost String
nominatimHost : (String) nominatim instance to use (default = 'nominatim.openstreetmap.org')
final
nominatimZoomLevel int?
nominatimZoomLevel : (int?) zoom level to use in nominatim requests. If set to null will use zoom level corresponding to current map zoom level (example: 18) (default = null)
final
onChanged → void Function(PickedData pickedData)?
onChanged : (callback) is trigger when you change marker location on map,return current PickedData of the Marker
final
onError → void Function(Exception e)?
onError : (callback) is trigger when an error occurs while fetching location
final
onPicked → void Function(PickedData pickedData)
onPicked : (callback) is trigger when you clicked on select location,return current PickedData of the Marker
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
searchBarBackgroundColor Color?
searchBarBackgroundColor : (Color) change the background color of the search bar
final
searchbarBorderRadius BorderRadiusGeometry?
searchbarBorderRadius : (BorderRadiusGeometry) change the border radius of the search bar
final
searchbarDebounceDuration Duration?
searchbarDebounceDuration : (Duration) change the duration of search debounce
final
searchBarHintColor Color?
searchBarHintColor : (Color) change the color of the search bar hint text
final
searchBarHintText String
searchBarHintText : (String) change the hint text of the search bar
final
searchbarInputBorder OutlineInputBorder?
searchbarInputBorder : (OutlineInputBorder) change the border of the search bar
final
searchbarInputFocusBorderp OutlineInputBorder?
searchbarInputFocusBorder : (OutlineInputBorder) change the border of the search bar when focused
final
searchBarTextColor Color?
searchBarTextColor : (Color) change the color of the search bar text
final
selectedLocationButtonTextStyle TextStyle
selectedLocationButtonTextStyle : set the style of the button text (default = TextStyle(fontSize: 20))
final
selectLocationButtonHeight double?
selectLocationButtonHeight : (double) change the height of the select Location button
final
selectLocationButtonLeadingIcon Widget?
selectLocationButtonLeadingIcon : (Widget) set the leading icon of the select location button
final
selectLocationButtonPositionBottom double?
selectLocationButtonPositionBottom : (double) change the bottom position of the select Location button (default = 3)
final
selectLocationButtonPositionLeft double?
selectLocationButtonPositionLeft : (double) change the left position of the select Location button (default = 0)
final
selectLocationButtonPositionRight double?
selectLocationButtonPositionRight : (double) change the right position of the select Location button (default = 0)
final
selectLocationButtonPositionTop double?
selectLocationButtonPositionTop : (double) change the top position of the select Location button (default = null)
final
selectLocationButtonStyle ButtonStyle?
selectLocationButtonStyle : (ButtonStyle) change the style of the select Location button
final
selectLocationButtonText String
selectLocationButtonText : (String) set the text of the select location button (default = 'Set Current Location')
final
selectLocationButtonWidth double?
selectLocationButtonWidth : (double) change the width of the select Location button
final
showContributorBadgeForOSM bool
showContributorBadgeForOSM : (bool) for copyright of osm, we need to add badge in bottom of the map (default false)
final
showCurrentLocationPointer bool
showCurrentLocationPointer : (bool) if is true, your current location will be shown on the map (default = true)
final
showLocationController bool
showLocationController : (bool) enable/disable locate me button (default = true)
final
showSearchBar bool
showSearchBar : (bool) enable/disable search bar (default = true)
final
showSelectLocationButton bool
showSelectLocationButton : (bool) enable/disable select location button (default = true)
final
showZoomController bool
showZoomController : (bool) enable/disable zoom in and zoom out buttons (default = true)
final
stepZoom double
stepZoom : (double) set default step zoom value (default = 1)
final
trackMyPosition bool
trackMyPosition : (bool) if is true, map will track your your location on the map initialization and makes inittial position of the pointer your current location (default = false)
final
urlTemplate String
urlTemplate : (String) set the url template of the tile layer to get the data from the api (makes you apply your own style to the map) (default = 'https://tile.openstreetmap.org/{z}/{x}/{y}.png')
final
zoomButtonsBackgroundColor Color?
zoomButtonsBackgroundColor : (Color) change the background color of the zoom buttons
final
zoomButtonsColor Color?
zoomButtonsColor : (Color) change the color of the zoom buttons icons
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<FlutterLocationPicker>
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}) 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