first ios1
This commit is contained in:
11
lib/constant/credential.dart
Normal file
11
lib/constant/credential.dart
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
class AppCredintials {
|
||||||
|
static const String basicAuthCredentials = 'hamzaayedphp:malDEV@2101';
|
||||||
|
static const String serverAPI = 'fgdgf';
|
||||||
|
|
||||||
|
static const String mapAPIKEY = 'AIzaSyCyfwRXTwSTLOFQSQgN5p7QZgGJVZnEKq0';
|
||||||
|
String getBasicAuthCredentials() {
|
||||||
|
return base64Encode(utf8.encode(basicAuthCredentials));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ import 'package:get/get.dart';
|
|||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||||
import 'package:google_polyline_algorithm/google_polyline_algorithm.dart';
|
import 'package:google_polyline_algorithm/google_polyline_algorithm.dart';
|
||||||
|
import 'package:location/location.dart';
|
||||||
import 'package:ride/constant/colors.dart';
|
import 'package:ride/constant/colors.dart';
|
||||||
import 'package:ride/constant/credential.dart';
|
import 'package:ride/constant/credential.dart';
|
||||||
import 'package:ride/constant/links.dart';
|
import 'package:ride/constant/links.dart';
|
||||||
@@ -18,12 +19,13 @@ class MapController extends GetxController {
|
|||||||
LatLngBounds? boundsdata;
|
LatLngBounds? boundsdata;
|
||||||
List<Marker> markers = [];
|
List<Marker> markers = [];
|
||||||
List<Polyline> polylines = [];
|
List<Polyline> polylines = [];
|
||||||
LatLng mylocation = const LatLng(32.111965, 36.067427);
|
late LatLng mylocation;
|
||||||
LatLng mydestination = const LatLng(32.115295, 36.064773);
|
LatLng mydestination = const LatLng(32.115295, 36.064773);
|
||||||
final List<LatLng> polylineCoordinates = [];
|
final List<LatLng> polylineCoordinates = [];
|
||||||
BitmapDescriptor markerIcon = BitmapDescriptor.defaultMarker;
|
BitmapDescriptor markerIcon = BitmapDescriptor.defaultMarker;
|
||||||
double height = 200;
|
double height = 200;
|
||||||
|
final location = Location();
|
||||||
|
late LocationData currentLocation;
|
||||||
changeHeight() {
|
changeHeight() {
|
||||||
if (places.isEmpty) {
|
if (places.isEmpty) {
|
||||||
height = 0;
|
height = 0;
|
||||||
@@ -75,6 +77,43 @@ class MapController extends GetxController {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> getLocation() async {
|
||||||
|
bool serviceEnabled;
|
||||||
|
PermissionStatus permissionGranted;
|
||||||
|
|
||||||
|
// Check if location services are enabled
|
||||||
|
serviceEnabled = await location.serviceEnabled();
|
||||||
|
if (!serviceEnabled) {
|
||||||
|
serviceEnabled = await location.requestService();
|
||||||
|
if (!serviceEnabled) {
|
||||||
|
// Location services are still not enabled, handle the error
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the app has permission to access location
|
||||||
|
permissionGranted = await location.hasPermission();
|
||||||
|
if (permissionGranted == PermissionStatus.denied) {
|
||||||
|
permissionGranted = await location.requestPermission();
|
||||||
|
if (permissionGranted != PermissionStatus.granted) {
|
||||||
|
// Location permission is still not granted, handle the error
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the current location
|
||||||
|
LocationData _locationData = await location.getLocation();
|
||||||
|
mylocation =
|
||||||
|
(_locationData.latitude != null && _locationData.longitude != null
|
||||||
|
? LatLng(_locationData.latitude!, _locationData.longitude!)
|
||||||
|
: null)!;
|
||||||
|
// print(currentLocation.accuracy);
|
||||||
|
// print(currentLocation.latitude);
|
||||||
|
// print(currentLocation.time);
|
||||||
|
// print('//////////////////////////////////////');
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
GoogleMapController? mapController;
|
GoogleMapController? mapController;
|
||||||
void onMapCreated(GoogleMapController controller) {
|
void onMapCreated(GoogleMapController controller) {
|
||||||
mapController = controller;
|
mapController = controller;
|
||||||
@@ -103,19 +142,9 @@ class MapController extends GetxController {
|
|||||||
double lng = points[i][1].toDouble();
|
double lng = points[i][1].toDouble();
|
||||||
polylineCoordinates.add(LatLng(lat, lng));
|
polylineCoordinates.add(LatLng(lat, lng));
|
||||||
}
|
}
|
||||||
// // Define the northeast and southwest coordinates
|
// Define the northeast and southwest coordinates
|
||||||
final bounds = response["routes"][0]["bounds"];
|
final bounds = response["routes"][0]["bounds"];
|
||||||
// LatLng northeast =
|
|
||||||
// LatLng(bounds['northeast']['lat'], bounds['northeast']['lng']);
|
|
||||||
// LatLng southwest =
|
|
||||||
// LatLng(bounds['southwest']['lat'], bounds['southwest']['lng']);
|
|
||||||
|
|
||||||
// // Create the LatLngBounds using the coordinates
|
|
||||||
// boundsdata = LatLngBounds(northeast: northeast, southwest: southwest);
|
|
||||||
// update();
|
|
||||||
// print(boundsdata);
|
|
||||||
////////////////////////////////////////////
|
|
||||||
// Create the northeast and southwest LatLng objects
|
|
||||||
LatLng northeast =
|
LatLng northeast =
|
||||||
LatLng(bounds['northeast']['lat'], bounds['northeast']['lng']);
|
LatLng(bounds['northeast']['lat'], bounds['northeast']['lng']);
|
||||||
LatLng southwest =
|
LatLng southwest =
|
||||||
@@ -267,7 +296,7 @@ class MapController extends GetxController {
|
|||||||
// getPolyLine();
|
// getPolyLine();
|
||||||
// getMap();
|
// getMap();
|
||||||
addCustomPicker();
|
addCustomPicker();
|
||||||
|
getLocation();
|
||||||
super.onInit();
|
super.onInit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ class MapPage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
onConfirm: () {
|
onConfirm: () {
|
||||||
controller.clearpolyline();
|
controller.clearpolyline();
|
||||||
controller.getMap('32.111946, 36.067396',
|
controller.getMap(
|
||||||
|
'${controller.mylocation.latitude}, ${controller.mylocation.longitude}',
|
||||||
'${argument.latitude.toString()},${argument.longitude.toString()}');
|
'${argument.latitude.toString()},${argument.longitude.toString()}');
|
||||||
|
|
||||||
Get.back();
|
Get.back();
|
||||||
|
|||||||
Reference in New Issue
Block a user