Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Dictionary 在flatter中显示JSON请求创建的标记时出现问题_Dictionary_Dart_Flutter_Maps - Fatal编程技术网

Dictionary 在flatter中显示JSON请求创建的标记时出现问题

Dictionary 在flatter中显示JSON请求创建的标记时出现问题,dictionary,dart,flutter,maps,Dictionary,Dart,Flutter,Maps,我正在尝试创建带有JSON、响应的标记,JSON y正常工作,映射也正常工作,但标记没有显示在映射中 我知道代码有问题,但我找不到解决方案,或者类似的方法来修复它` var farmcias = Farmacia.fromJson(jsonDecode(response.body)); for (var result in farmcias.result.toList()) { titulo = result?.title; calle = result?.ca

我正在尝试创建带有JSON、响应的标记,JSON y正常工作,映射也正常工作,但标记没有显示在映射中

我知道代码有问题,但我找不到解决方案,或者类似的方法来修复它`

 var farmcias = Farmacia.fromJson(jsonDecode(response.body));
    for (var result in farmcias.result.toList()) {
      titulo = result?.title;
      calle = result?.calle;
      lat = result?.geometry.coordinates[0];
      long = result?.geometry.coordinates[1];

      markers.add( Marker(
    width: 80.0,
    height: 80.0,
    point: new LatLng(lat, long),
    builder: (ctx) =>
     Container(
      child:  FlutterLogo(colors: Colors.purple),
    ),
  ));
  return markers;
}
  }


  @override
  Widget build(BuildContext context) {
    FetchJSON();
    return new Scaffold(
      body: new Padding(
        padding: new EdgeInsets.all(8.0),
        child: new Column(
          children: [
            new Padding(
              padding: new EdgeInsets.only(top: 18.0, bottom: 18.0),
            ),
            new Flexible(
              child: new FlutterMap(
                options: new MapOptions(
                  center: new LatLng(41.652833, -0.889830),
                  zoom: 12.0,
                ),
                layers: [
                  new TileLayerOptions(
                      urlTemplate:
                      "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
                      subdomains: ['a', 'b', 'c']),
                  new MarkerLayerOptions(markers: markers)
                ],`

谢谢大家。

您可能正在构建UI,而无需等待完成。尝试使用wait。我在请求中有wait,以获得响应FetchJSON()async{var response=await http.get('您可能在构建UI时没有等待FetchJSON完成。请尝试使用await。我在请求中有wait来获取响应。'FetchJSON()async{var response=await http.get('