В Flutter, независимо от того, какой файл json я пытаюсь декодировать, я получаю ту же самую выше названную ошибку. Первоначально я думал, что это что-то с моим проектом, но после запуска нового шаблона проекта Flutter я все еще получаю ту же ошибку. У меня есть файл json в моей папке root, и я добавил их в файл pubspe c .yaml:
assets:
- Sample-JSON-data.json
- Sample-employee-JSON-data.json
Код Main.dart на данный момент:
var jsonString = 'Sample-JSON-data.json';
var response = jsonDecode(jsonString);
print(response);
Я подтвердил свои данные json на нескольких испытательных участках, а также попробовал различные методы в документации Flutter . Json данные:
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
151.0763783444317,
-33.98045132346684
]
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
151.07774912725728,
-33.97470462237792
]
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
151.07774912725728,
-33.97470462237792
]
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
151.07774912725728,
-33.97470462237792
]
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
151.0763783444317,
-33.98045132346684
]
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
151.07774912725728,
-33.97470462237792
]
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
151.07774912725728,
-33.97470462237792
]
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
151.07774912725728,
-33.97470462237792
]
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
151.0763783444317,
-33.98045132346684
]
}
}
]
}