Skip to content

Instantly share code, notes, and snippets.

@deven98
Created January 6, 2019 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deven98/d7748824680b1b3b66d5eba33f352bcf to your computer and use it in GitHub Desktop.
Save deven98/d7748824680b1b3b66d5eba33f352bcf to your computer and use it in GitHub Desktop.
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