Compare commits
No commits in common. "ef8c5e9039934b77fd8c77d93193695181772eb2" and "4b384b378a02212f19e3fadad31cce551a6801d1" have entirely different histories.
ef8c5e9039
...
4b384b378a
@ -8,6 +8,7 @@ import 'package:app/view/locationSearch.dart';
|
|||||||
import 'package:app/view/status.dart';
|
import 'package:app/view/status.dart';
|
||||||
import 'package:app/view/map.dart';
|
import 'package:app/view/map.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_map/flutter_map.dart';
|
||||||
import 'package:geolocator/geolocator.dart';
|
import 'package:geolocator/geolocator.dart';
|
||||||
import 'package:latlong2/latlong.dart';
|
import 'package:latlong2/latlong.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
@ -23,18 +24,14 @@ class _HomePageState extends State<HomeView> {
|
|||||||
bool locationEnabled = false;
|
bool locationEnabled = false;
|
||||||
|
|
||||||
Future<LatLng?> getLatLng() async {
|
Future<LatLng?> getLatLng() async {
|
||||||
LocationPermission permission = await Geolocator.checkPermission();
|
LocationPermission permissionStatus = await Geolocator.checkPermission();
|
||||||
if (permission == LocationPermission.denied) {
|
if (permissionStatus == LocationPermission.denied) {
|
||||||
permission = await Geolocator.requestPermission();
|
permissionStatus = await Geolocator.requestPermission();
|
||||||
if (permission == LocationPermission.denied || permission == LocationPermission.deniedForever) {
|
if (permissionStatus == LocationPermission.denied || permissionStatus == LocationPermission.deniedForever) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setState(() {
|
|
||||||
locationEnabled = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
Position? position;
|
Position? position;
|
||||||
try {
|
try {
|
||||||
position = await Geolocator.getCurrentPosition();
|
position = await Geolocator.getCurrentPosition();
|
||||||
@ -48,16 +45,6 @@ class _HomePageState extends State<HomeView> {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
|
|
||||||
Geolocator.checkPermission().then((permission) => setState(() {
|
|
||||||
locationEnabled = permission != LocationPermission.denied && permission != LocationPermission.deniedForever;
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
@ -104,6 +91,9 @@ class _HomePageState extends State<HomeView> {
|
|||||||
LatLng? latLng = await getLatLng();
|
LatLng? latLng = await getLatLng();
|
||||||
if (latLng != null) {
|
if (latLng != null) {
|
||||||
mapState.getMapController.move(latLng, 16);
|
mapState.getMapController.move(latLng, 16);
|
||||||
|
setState(() {
|
||||||
|
locationEnabled = true;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
mapState.setLoading(false);
|
mapState.setLoading(false);
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user