Created
January 6, 2019 14:26
-
-
Save deven98/d7748824680b1b3b66d5eba33f352bcf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:location/location.dart'; | |
class ListenPage extends StatefulWidget { | |
@override | |
_ListenPageState createState() => _ListenPageState(); | |
} | |
class _ListenPageState extends State<ListenPage> { | |
Location location = Location(); | |
Map<String, double> currentLocation; | |
@override | |
void initState() { | |
// TODO: implement initState | |
super.initState(); | |
location.onLocationChanged().listen((value) { | |
setState(() { | |
currentLocation = value; | |
}); | |
}); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar(), | |
body: Column( | |
children: <Widget>[ | |
currentLocation == null | |
? CircularProgressIndicator() | |
: Text("Location:" + currentLocation["latitude"].toString() + " " + currentLocation["longitude"].toString()), | |
], | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment