Untitled

mail@pastecode.io avatar
unknown
dart
3 years ago
1.5 kB
1
Indexable
Never
 void customerSocketsOn() {
    WebServices.socket.on("CustomerRequest", (data) async {
      var result = jsonDecode(data);
      JobInfoModel _jobInfoModel = JobInfoModel.fromJson(result);
      if (!mounted) return;
      setState(() {
        print(data);

        _originLatitude = _jobInfoModel.data.requestInfo.beginLat;
        _originLongitude = _jobInfoModel.data.requestInfo.beginLng;
        _destLatitude = _jobInfoModel.data.requestInfo.endLat;
        _destLongitude = _jobInfoModel.data.requestInfo.endLng;
      });
      if (_originLatitude != null &&
          _originLongitude != null &&
          _destLatitude != null &&
          _destLongitude != null) {
        startAndDestinationMarker();
        setState(() {
          toCustomer = false;
        });
        await getpolylines(_originLatitude, _originLongitude, _destLatitude,
                _destLongitude)
            .then((v) {
          setState(() {
            isJobAvailable = true;
          });
        });
        reverseGeocodingSearch(address.LatLon(_destLatitude, _destLongitude));
      }
    });
  }
  
  
  
// accept or denied
 void responseToCustomer(bool confirm) {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['DeviceID'] = Constant.deviceID;
    data['DriverID'] = _driverInfoModel.sId;
    data['Confirm'] = confirm;
    data['DeviceName'] = Constant.myDevice.deviceName;
    data['DriverName'] = _driverInfoModel.name + " " + _driverInfoModel.surname;
    WebServices.socket.emit('CustomerResponse', data);
  }