1 year ago
#358739
nullonprog
Execution failed for task ':location:parseDebugLocalResources'
i'm trying to run my project , i have this page where i want to get current location of the user but i get a message error when i run it
Message error ** Execution failed for task ':location:parseDebugLocalResources'.
Could not resolve all files for configuration ':location:androidApis'.
Failed to transform android.jar to match attributes {artifactType=android-platform-attr, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
> Execution failed for PlatformAttrTransform:
C:\Users\lenovo\AppData\Local\Android\sdk\platforms\android-30\android.jar. > C:\Users\lenovo\AppData\Local\Android\sdk\platforms\android-30\android.jar **
The code in the page
// ignore_for_file: deprecated_member_use
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';
import 'package:location/location.dart';
import '../rounded_button.dart';
class DemandeList extends StatefulWidget {
@override
_DemandeList createState() => _DemandeList();
}
class _DemandeList extends State<DemandeList>{
late bool _serviceEnabled;
late PermissionStatus _permissionGranted;
LocationData? _userLocation;
Future<void> _getUserLocation() async {
Location location = Location();
// Check if location service is enable
_serviceEnabled = await location.serviceEnabled();
if (!_serviceEnabled) {
_serviceEnabled = await location.requestService();
if (!_serviceEnabled) {
return;
}
}
// Check if permission is granted
_permissionGranted = await location.hasPermission();
if (_permissionGranted == PermissionStatus.denied) {
_permissionGranted = await location.requestPermission();
if (_permissionGranted != PermissionStatus.granted) {
return;
}
}
final _locationData = await location.getLocation();
setState(() {
_userLocation = _locationData;
});
}
final db = FirebaseFirestore.instance;
String? Key ;
@override
void initState() {
// TODO: implement initState
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Listes des demandes"),
centerTitle: true,
),
body: StreamBuilder<QuerySnapshot>(
stream: db.collection('ambulance')
.where("etat", isEqualTo: "en cours")
.snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return Center(
child: CircularProgressIndicator(),
);
} else
return ListView(
children: snapshot.data!.docs.map((doc) {
int lng;
int lat;
return Card(
child: ListTile(
trailing: Text("Accepter",
style: TextStyle(
color: Colors.green,fontSize: 15
),
),
title: new Text(doc['id']) ,
subtitle: new Text(doc['etat']),
onTap: () => {
_getUserLocation,
lat = _userLocation?.latitude as int ,
lng = _userLocation?.longitude as int ,
db.collection("position").add({'lat': lat , "lng": lng ,}),
db.collection("ambulance").doc(doc.id).update({"etat": 'Accept' }),
}
),
);
}).toList(),
);
},
),
);
}
}
firebase
flutter
dart
geolocation
geolocator
0 Answers
Your Answer