Я хочу сделать полигональные карты во флаттере android, используя данные о долготе и широте с сервера, но я пытался использовать цикл point.add, он возвращает
Performing hot reload...
Reloaded 6 of 607 libraries in 1,734ms.
D/EGL_emulation(17903): eglMakeCurrent: 0xdfa1a120: ver 2 0 (tinfo 0xdfa0f640)
D/EGL_emulation(17903): eglMakeCurrent: 0xb68c3d00: ver 1 0 (tinfo 0xc4d5f300)
W/ani_mapping_io(17903): Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed)
D/EGL_emulation(17903): eglMakeCurrent: 0xdfa1a120: ver 2 0 (tinfo 0xdfa0f640)
I/Google Maps Android API(17903): Google Play services package version: 19275022
W/ani_mapping_io(17903): Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed)
W/ani_mapping_io(17903): Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed)
W/ani_mapping_io(17903): Accessing hidden method Lsun/misc/Unsafe;->putLong(Ljava/lang/Object;JJ)V (greylist, linking, allowed)
E/GoogleMapController(17903): Cannot enable MyLocation layer as location permissions are not granted
D/HostConnection(17903): HostConnection::get() New Host Connection established 0xdfa499d0, tid 18433
D/HostConnection(17903): HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_vulkan ANDROID_EMU_deferred_vulkan_commands ANDROID_EMU_vulkan_null_optional_strings ANDROID_EMU_vulkan_create_resources_with_requirements ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_2
D/EGL_emulation(17903): eglMakeCurrent: 0xdfa1a120: ver 2 0 (tinfo 0xdfa0f640)
D/EGL_emulation(17903): eglCreateContext: 0xb090f7e0: maj 1 min 0 rcv 1
D/EGL_emulation(17903): eglMakeCurrent: 0xb090f7e0: ver 1 0 (tinfo 0xc4d5f2f0)
E/flutter (17903): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: type 'String' is not a subtype of type 'int'
E/flutter (17903): #0 new DLahan.formJson (package:dutatani_mapping_iot/model/dLahan.dart:17:22)
E/flutter (17903): #1 _DetailLahanState.fetchData.<anonymous closure> (package:dutatani_mapping_iot/detail_lahan.dart:83:34)
E/flutter (17903): #2 State.setState (package:flutter/src/widgets/framework.dart:1148:30)
E/flutter (17903): #3 _DetailLahanState.fetchData (package:dutatani_mapping_iot/detail_lahan.dart:80:7)
E/flutter (17903): <asynchronous suspension>
E/flutter (17903): #4 _DetailLahanState.initState (package:dutatani_mapping_iot/detail_lahan.dart:121:5)
E/flutter (17903): #5 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4355:58)
любое предложение или руководство для цикла данные во флаттере, пожалуйста .. вот мой код
List <DLahan> _listDetail = [];
final List<LatLng> points = <LatLng>[];
Future<Null> fetchData() async{
_listDetail.clear();
final response =
await http.get("<URL>);
// print(response.body);
if(response.statusCode == 200){
final detailLahan = jsonDecode(response.body);
setState(() {
for (Map i in detailLahan){
// points.add(_createLatLng(DLahan.formJson(i).lat, DLahan.formJson(i).longt));
_listDetail.add(DLahan.formJson(i));
}
});
_createPoints();
_add();
}
}
List<LatLng> _createPoints() {
final List<LatLng> points = <LatLng>[];
//not working
// for (int i=0 ; i<_listDetail.length;i++){
// points.add(_createLatLng(_listDetail[i].lat, _listDetail[i].longt));
// }
//not working
//not working
for(var i in _listDetail){
points.add(_createLatLng(i.lat, i.longt));
}
//not working
//Manually adding long lat it works but it cant use for me
// points.add(_createLatLng(-7.------, 1--.----));
// points.add(_createLatLng(-7.------, 1--.----));
// points.add(_createLatLng(-7.------, 1--.----));
// points.add(_createLatLng(-7.------, 1--.----));
//Manually adding long lat it works
return points;
}
LatLng _createLatLng(double lat, double lng) {
return LatLng(lat, lng);
}
я использовал ручное добавление, точка работает, но это не моя цель, и это мой класс
class DLahan{
final int id_detail;
final int id_lahan;
final double lat;
final double longt;
final int indeks;
DLahan({
this.id_detail,
this.id_lahan,
this.lat,
this.longt,
this.indeks
});
factory DLahan.formJson(Map <String, dynamic> json){
return new DLahan(
id_detail: int.parse(json['id_detail']),
id_lahan: int.parse(json['ID_Lahan']),
lat: double.parse(json['lat']),
longt: double.parse(json['longt']),
indeks: int.parse(json['indeks'])
);
}
}
извините, если мой неправильная грамматика