I am currently building an app to get a data from a json api. I want to get the number 54 from the json code.
here is the json link
I have tried making model cla
If you look at your json, you will see that it is entirely surrounded by [...]
, meaning that it is a json array. json.decode
will convert this into a Dart List<Map<String, dynamic>>
. It looks like you want the first / zero'th element of this array/list.
Change:
var line = teerModel["text"].replaceAll(new RegExp(r"(\s\n)"), "");
to
var line = teerModel[0]["text"].replaceAll(new RegExp(r"(\s\n)"), "");
Don't forget to call setState
so that your widget rebuilds itself.