JSON字符串映射_启动器颤振

JSON字符串映射_启动器颤振,json,string,flutter,double,Json,String,Flutter,Double,我已经用json和listview.builder列出了一个列表。所有项目都是字符串。其中2项包含地图发射器发射导航的坐标 JSON示例: { "image": "https://merakiapp.be/wp-content/uploads/2021/05/No-image.jpg", "title": "Zakros", "type": "Historical

我已经用json和listview.builder列出了一个列表。所有项目都是字符串。其中2项包含地图发射器发射导航的坐标

JSON示例:

{
    "image": "https://merakiapp.be/wp-content/uploads/2021/05/No-image.jpg",
    "title": "Zakros",
    "type": "Historical site",
    "prefecture": "Lassithi",
    "description": "There are Minoan palatial complexes in Knossos.",
    "open": "In Summer daily open from 08:00 until 20:00",
    "fee": "Up to 25: FREE\nSeniors over 65: EUR 3\nAdults (25-65): EUR 6",
    "walkingtime": "N/A",
    "walkingdistance": "N/A",
    "nav1": "35.097112768251",
    "nav2": "26.2606381884158"
}
但是我不能让map_启动器工作,因为坐标是字符串。但是,当我将它们更改为double时,我不知道如何更正页面中的模型和代码

模型示例:

class archaeological {
  String image;
  String title;
  String description;
  String nav1;
  String nav2;
  String open;
  String fee;
  String prefecture;
  String walkingtime;
  String walkingdistance;
  String type;

  archaeological({
    this.image,
    this.title,
    this.description,
    this.nav1,
    this.nav2,
    this.open,
    this.fee,
    this.prefecture,
    this.type,
  });

  archaeological.fromJson(Map<String, dynamic> json) {
    image = json['image'];
    title = json['title'];
    description = json['description'];
    nav1 = json['nav1'];
    nav2 = json['nav2'];
    open = json['open'];
    fee = json['fee'];
    prefecture = json['prefecture'];
    type = json['type'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['image'] = this.image;
    data['title'] = this.title;
    data['description'] = this.description;
    data['nav1'] = this.nav1;
    data['nav2'] = this.nav2;
    data['open'] = this.open;
    data['fee'] = this.fee;
    data['prefecture'] = this.prefecture;
    data['type'] = this.type;
    return data;
  }
}
class{
字符串图像;
字符串标题;
字符串描述;
字符串nav1;
字符串nav2;
弦开;
串费;
弦县;
字符串行走时间;
串走距离;
字符串类型;
考古的({
这个,这个形象,,
这个名字,
这个.说明,,
这是nav1,,
这是nav2,
这个,打开,
这个,费用,,
这个县,,
这个.类型,,
});
fromJson(映射json){
image=json['image'];
title=json['title'];
description=json['description'];
nav1=json['nav1'];
nav2=json['nav2'];
open=json['open'];
fee=json['fee'];
地区=json[‘地区’];
type=json['type'];
}
映射到JSON(){
最终地图数据=新地图();
数据['image']=this.image;
数据['title']=this.title;
数据['description']=this.description;
数据['nav1']=this.nav1;
数据['nav2']=this.nav2;
数据['open']=this.open;
数据['fee']=此项费用;
数据['authority']=this.authority;
数据['type']=this.type;
返回数据;
}
}
页面代码:

class _CreteArchaeologicalState extends State<CreteArchaeological> {
  final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();

  Future<dynamic> data;
  int totalRecords;
  List<archaeological> archaeologicalList = [];
  List<archaeological> filteredArchaeological = [];

  @override
  void initState() {
    super.initState();
    getArchaeological();
  }
  void getArchaeological() async {
    String data = await DefaultAssetBundle.of(context)
        .loadString("assets/data/archaeological.json");
    final List<dynamic> jsonResult = json.decode(data);
    totalRecords = jsonResult.length;
    List<archaeological> _archaeologicalList =
    jsonResult.map((p) => archaeological.fromJson(p)).toList();

    setState(() {
      archaeologicalList = _archaeologicalList;
      filteredArchaeological = _archaeologicalList;
    });
  }
class\u cretearcheologicalState扩展状态{
最终GlobalKey _scaffoldKey=新的GlobalKey();
未来数据;
国际总记录;
列表考古学家=[];
列表过滤器数据逻辑=[];
@凌驾
void initState(){
super.initState();
geta();
}
void gets()异步{
字符串数据=等待DefaultAssetBundle.of(上下文)
.loadString(“资产/数据/考古.json”);
最终列表jsonResult=json.decode(数据);
totalRecords=jsonResult.length;
列表\u考古学家=
jsonResult.map((p)=>arcoholic.fromJson(p)).toList();
设置状态(){
考古学家=_考古学家;
filteredArchaeological=\u考古学家;
});
}