get my location in flutter

import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';

void main() => runApp(MapScreen());

class MapScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: "Map",
      home: MapActivity(),
    );
  }
}

class MapActivity extends StatefulWidget {
  @override
  _MapActivityState createState() => _MapActivityState();
}

class _MapActivityState extends State<MapActivity> {
  LatLng _center ;
  Position currentLocation;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    getUserLocation();
  }

 Future<Position> locateUser() async {
    return Geolocator()
        .getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
  }

  getUserLocation() async {
    currentLocation = await locateUser();
    setState(() {
      _center = LatLng(currentLocation.latitude, currentLocation.longitude);
    });
    print('center $_center');
  }
}

4
1
Cristina78 110 points

                                    &lt;uses-permission android:name=&quot;android.permission.ACCESS_FINE_LOCATION&quot; /&gt;&lt;uses-permission android:name=&quot;android.permission.ACCESS_COARSE_LOCATION&quot; /&gt;

4 (1 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
hoe to get current location in flutter how to do location in flutter flutter get current location example hwo to know flutter location check location settings flutter how to get current location flutter get my location using latlng flutter flutter location get current location on map get realtime location in flutter show current location using flutter flutter check location access get gps location flutter flutter js get current location flutter store current location getlive location in flutter user current location in flutter flutter how to know near our location location search up flutter how to check the location of flutter flutter find location flutter get location by location plugin how find my location in fluute flutter.io get location code get current location name in flutter flutter search location location getter flutter find near location flutter flutter current location with fluttermap get location in flutter sample get current location address in flutter from coordinates find location in flutter flutter get current location address get location from flutter widget how to get my current location from flutter app get current location name flutter get current location nam in flutter flutter location search flutter dart location get your current location flutter flutter get location data from Location manually set location in flutter how to get current location in flutter open with my location flutter using location with flutter flutter curent location using location package get location in dart show city location flutter flutter how to get the current location location detector flutter get current location city in flutter get location and address from flutter how to see flutter location flutter how to get location flutter latlong to curriunt location get accurate current location in flutter How to get current location in flutter app of google maps detect location flutter current location in flutter flutter current location geo use location flutter flutter get current location using location package flutter get current location ios how to know location using flutter get current location using location package flutter how to show current location in flutter flutter get app location find location flutter location flutter' how to activate my current location in flutter flutter show location flutter get location by gps Detect location in flutter flutter going from current location to another location flutter get device location flutter current location flutter location access flutter get location name how to find flutter location how to get the location of a phone flutter how to get location info in flutter take from location to location flutter get location access flutter how to get location in flutter Location Options flutter flutter user locatioon location.getLocation() ios flutter get location on ios flutter how to get latitude and longitude in flutter your location in flutter localtion in Flutter get location without using flutter packages how to get location using api in flutter get current location and on location changed in flutter update current location in flutter update currentlocation in flutter get current location flutter using location flutter location change settings get user location in flutter using api how to get user location using api in flutter get user location using flutter and api flutter package to get location get location in flutter with permission how to get location in flutter how to tracking location in simulator flutter how to get current location in flutter get user current location flutter geolocator package flutter permission flutter geolocation provider example flutter gps location flutter location when in use user location flutter get city name in flutter app how to get mobile current city name in flutter CurrentLocationWidget flutter show near by location flutter locations package flutter how to use lcoation plugin flutter flutter user puts location how to use location plugin flutter get current lat long flutter flutter code to get users location flutter get gps location how to check if user is in radius of a location flutter location by ip flutter how to put coordinates in simulator ios flutter flutter location plugin example check if latitude and longitude is same in flutter get user device address from location flutter example get user device location flutter example get user device location flutter using location in flutter location settings flutter location libraries flutter _locationservice flutter request enablre flutter location based app location services in flutter get location services with location package in flutter access location coordinates in flutter location flutter get latitude and longitude flutter window.location flutter how to get current location coordinates how to find the latitude and longitude of the current user in flutter location capture flutter flutter get longitude and latitude location name in flutter recenter my location flutter how to set high accuracy location in flutter uing location package how to read the current user location on app start flutter CHECK location permission in flutter geolocator getting current location in flutter location services flutter how to get location of user in flutter flutter add locatio service to ios access location from flutter get location fultter flutter get location id get user current location using location plugin in flutter location plugin in flutter how to ask user to enable gps using geolocator package how to get location name in flutter save device geolocation flutter flutter location full example flutter get last known location how to retrieve location flutter get lat lan flutter geo location in flutter get current location latitude and longitude flutter get latitude and longitude flutter get device location flutter get current coordinates into flutter get user coordinates in flutter get user location flutter flutter get town location geolocation flutter my location flutter location address in flutter get current position geolocator flutter get accurate location flutter how to get users location in flutter geolocation package flutter flutter geolocator permission get the current location of the app using flutter Get the current location when entering the app flutter flutter location service geolocator flutter get current location after how to get current locationin flutter location data in flutter Location package flutter flutter user current location flutter location services send on button click android and ios location with flutter geolocation services flutter location accuracy flutter current palce in flutter flutter get current location sweden get city with gps location Flutter hot to print a user location in flutter flutter get user location flutter determine location flutter pluglin locator latlng position library in flutter getting users location in flutter getcurrent psition flutter getcurrentposition flutter get users location in flutter flutter get city by geolocation flutter location LocationData set flutter go to current location flutter get location permission and get coordinate geolocator flutter flutter get user location permission locationdata set current location flutter get device current location flutter flutter validate location address fluttter get current address with geolocator flutter get my current location address Location location = Location(); flutter Location() flutter continuous lat lang using flutter flutter location plugin get users location flutter flutter geolocator android manifest location permission locatio service flutter get user address flutter flutter get coordinates flutter geolocator get location request user location flutter where to find flutter location geolocator get user location flutter geolocator get user location get userlocation flutter get currentlocation flutter geolocator aNDROID GET CURRENT LOCATION flutter\ how to get location without location permission in flutter how o get location without location permission in flutter flutter create location getting address flutter location flutter plugin get current location coordinates flutter get location name in flutter flutter location app location library flutter get exact location of device in flutter location in flutter how to get continous updated location of user flutter flutter get device speed flutter geolocator how to get the geo location in the flutter geolocator android flutter get location flutter get current location flutter geolocation flutter get current position flutter access gps Geolocator().placemarkFromAddress(searchAddress) flutter location listen GPS to capture location in Flutter fetching location in flutter The name 'LocationAccuracy' flutter how to get current location of user in flutter comment utilse le plugin de geolocalisation flutter get loaction from the latitude and longitude in the flutter app get current location of the device in Flutter flutter location class flutter location package bloc flutter get my current location flutter access location get location in flutter geolocator get current position flutter flutter find lat and long flutter device current location get current user location flutter get device position flutter flutter automatic location detection tutorial flutter automatic location detection example flutter automatic location detection location using flutter flutter location package how to get accurate latitude and longitude in android using flutter if location is around current location flutter if current location is around lat long flutter get current latitude and longitude flutter get current Latlng android flutter current android location flutter current location flutter flutter get current location coordinates current position flutter get my location in flutter location in flutter flutter plugin location get current location in flutter flutter location how to get users latitude and longitude in flutter location flutter flutter get location location flutter get lat long flutter flutter location plugin end location listener flutter get current location flutter fine location flutter lat long flutter location&uml; flutter get location latitude flutter location get location&uml; flutter find place from coordinates flutter get place from coordinates location: flutter how to send location automatically on flutter flutter user location get the location of mobile with flutter flutter locaion user location in flutter forceAndroidLocationManager in flutter get currunt location in flutter flutter location example
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source