Home > Mobile >  A value type of double cannot be assigned to value type of Double,
A value type of double cannot be assigned to value type of Double,

Time:08-16

I was working with reverse geocoding, where trying to store the user data with help of address model. However getting this error. I tried to add "?" sign while I am declaring variables in model adress class but it throws an exception.

Code of Address class:

class Address{
  String? placeFormattedAddress; 
  String? placeName;
  String? placeId;
  Double lattitude;
  Double longitude;

  Address({this.placeFormattedAddress, this.lattitude, this.longitude, this.placeId, this.placeName});
}

code where problem is coming:

class placeSearcherMethods{ static Future searchCoodinateAddress(Position position, context ) async { String placeAddress = "";

var response = await placeSearcher.getRequest(url);
if (response != "Failed!!"){
  placeAddress = response["results"][0]["formatted_address"];


  Address userPickUpAddress = new Address();
  userPickUpAddress.lattitude = position.latitude;
  userPickUpAddress.longitude = position.longitude;

  userPickUpAddress.placeName = placeAddress;


  Provider.of<carpool_data>(context, listen: false).update_pickup_location_address(userPickUpAddress);

  

}
return placeAddress;

} }

enter image description here

CodePudding user response:

Use double like double? lattitude;

class Address {
  String? placeFormattedAddress;
  String? placeName;
  String? placeId;
  double? lattitude;
  double? longitude;

  Address(
      {this.placeFormattedAddress,
      this.lattitude,
      this.longitude,
      this.placeId,
      this.placeName});
}

And remove import 'dart:ffi';

CodePudding user response:

Double should be lowercase

 double lattitude;
 double longitude;
  • Related