I am new in flutter, I am working on solving bugs in app. I want to print latitude and longitude of current user after 2 seconds, how can i do that?
void startTimer() {
const oneSec = const Duration(seconds: 2);
timer2 = new Timer.periodic(
oneSec,
(Timer timer) {
if (start == 0) {
timer.cancel();
setState(() {});
// });
} else {
// setState(() {
start--;
setState(() {
print("My current location ${homeMapCtrl!.userCurrentLatLng}");
});
// });
}
},
);
}
I am using this method and i am calling it in Consumer but it always run upto 1 to 100 seconds.
2
Answers
Use
Future.delayed
Use location package to get user location or you can checkout this link for example click here