我正在从JSON提取数据,但出现此错误。
...
switch (vModel->getDrawMode())
{
case 0: //GL_POINTS
//glPointSize(6.0);
glDrawArrays(GL_POINTS, 0, vModel->getVertices().size());
break;
case 1: //GL_LINES
//glEnable(GL_LINE_SMOOTH);
//GLint range[2];
//glGetIntegerv(GL_ALIASED_LINE_WIDTH_RANGE,range);
glDrawArrays(GL_LINES, 0, vModel->getVertices().size());
break;
case 2: //GL_LINE_LOOP
glDrawArrays(GL_LINE_LOOP, 0, vModel->getVertices().size());
break;
case 3: //GL_LINE_STRIP
glDrawArrays(GL_LINE_STRIP, 0, vModel->getVertices().size());
break;
}
上述错误的代码段-
> I/flutter ( 4999): NoSuchMethodError: The method '[]' was called on null.
> I/flutter ( 4999): Receiver: null
> I/flutter ( 4999): Tried calling: []("thumbnail")
打印输出(parsedJson)-
factory ImageLinks.fromJson(Map<String, dynamic> parsedJson) {
final finger = parsedJson["thumbnail"];
print(finger);
return ImageLinks(
thumb: finger,
);
}
请帮助!
答案 0 :(得分:0)
我想您正在使用http
软件包。您是否解码了响应数据?
Map<String, dynamic> parsedJson = jsonDecode(jsonString);