Note (below) city and location values are return correctly, but syntax for getting lat and long causes error. Code
Backendless.data.of(“worldcities”).findFirst().then((city) {
print(‘city = $city’);
var location = city![‘location’];
print(‘location = $location’);
var locationLatitude = location[“latitude”];
var locationLongitude = location[“longitude”];
print(‘lat = $locationLatitude, long = $locationLongitude’);
});
Return
I/flutter ( 5302): city = { … [correct city json data] …
I/flutter ( 5302): location = ‘POINT (34.77 32.08)’
E/flutter ( 5302): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: NoSuchMethodError: Class ‘Point’ has no instance method ‘[]’.
E/flutter ( 5302): Receiver: Instance of ‘Point’
E/flutter ( 5302): Tried calling:
Nikita, that syntax gives the same error: Class ‘Point’ has no instance method ‘[]’
After looking harder at the Backendless Point class, seems like the lat/long getters are y/x, so tried this:
Backendless.data.of(“worldcities”).findFirst().then((city) {
print(‘city = $city’);
var location = city![‘location’];
print(‘location = $location’);
var locationLatitude = location.y;
var locationLongitude = location.x;
print(‘lat = $locationLatitude, long = $locationLongitude’);
});
This works, returns:
I/flutter ( 6054): city = {country: China, city: Xinyang, … }
I/flutter ( 6054): location = ‘POINT (114.07 32.1304)’
I/flutter ( 6054): lat = 32.1304, long = 114.07
Seems like the Backedless.sdk updates are not getting back into the documentation or to the support staff.
Jim