[Solved] FLutter : The method ‘[]’ was called on null when iterating list


Just change your code to this!

Future<String> getJSONData() async {
    var response = await http.get(url);
    setState(() {
       var dataConvertedToJSON = json.decode(response.body);
       data = dataConvertedToJSON['data'];
       data = data[0]['INCI'];
    });
    return "Successfull";
}

@override
Widget build(BuildContext context) {
    return new MaterialApp( 
      home: new Scaffold( 
        appBar: new AppBar( title: new Text('List Test'), ), 
        body: new Center( 
          child: data != null ? Column(
            mainAxisAlignment: MainAxisAlignment.center, 
            children: <Widget>[
              for (var name in data) Text(name)
            ], 
          ) : new CircularProgressIndicator(), 
        ), 
      )
    ); 
} 

7

solved FLutter : The method ‘[]’ was called on null when iterating list