title: How to solve this "The getter 'length' was called on null"
body: <p>I have a php file hosted on my college server and when i run this file on the server it works very well. I can get the json data after running my php file which is in the link <a href="http://www.alkadhum-col.edu.iq/Teachers%20Activities/get.php" rel="nofollow noreferrer">http://www.alkadhum-col.edu.iq/Teachers%20Activities/get.php</a> but when i was unable to got them when i had tried that in flutter on the app screen got "the getter 'length'was called on null". </p>
  
  <pre><code>import 'package:flutter/material.dart';
  import 'package:http/http.dart' as http;
  import 'dart:convert';
  
  void main() {
  runApp(Workshops());
  }
  
  class Workshops extends StatelessWidget {
    @override
    Widget build(BuildContext mycontext) {
      return MaterialApp(
        home:Scaffold(
          appBar: AppBar(
            backgroundColor: Color.fromRGBO( 52, 73, 94, 1.0),
          automaticallyImplyLeading: false, // Don't show the leading button
          title: new Text("PHP with Flutter"),
          ),
  
          body: PostScreen(),
          )
      );
    }
  }    
  
  class PostScreen extends StatefulWidget {
    @override
    _PostScreenState createState() =&gt; _PostScreenState();
  }
  
  class _PostScreenState extends State&lt;PostScreen&gt; {
    List&lt;Post&gt; _postList = new List&lt;Post&gt;();
  
    Future&lt;List&lt;Post&gt;&gt; fetchPost() async {
      final response =
          await http.get('http://www.alkadhum-col.edu.iq/Teachers%20Activities/get.php');
  
      if (response.statusCode == 200) {
        // If the call to the server was successful, parse the JSON
        List&lt;dynamic&gt; values = new List&lt;dynamic&gt;();
        values = json.decode(response.body);
        if (values.length &gt; 0) {
          for (int i = 0; i &lt; values.length; i++) {
            if (values[i] != null) {
              Map&lt;String, dynamic&gt; map = values[i];
              _postList.add(Post.fromJson(map));
            }
          }
        }
        return _postList;
      } else {
        // If that call was not successful, throw an error.
        throw Exception('Failed to load post');
      }
    }
  
    @override
    Widget build(BuildContext context) {
      return FutureBuilder&lt;List&lt;Post&gt;&gt;(
        future: fetchPost(),
        builder: (_, AsyncSnapshot&lt;List&lt;Post&gt;&gt; snapshot) {
          if (snapshot.connectionState == ConnectionState.waiting) {
            return Center(child: CircularProgressIndicator());
          }
  
          return ListView.builder(
            itemCount: snapshot.data.length,
            itemBuilder: (_, index) {
              //dynamic post = snapshot.data[index];
              return (Container(
                margin: EdgeInsets.symmetric(vertical: 2.0, horizontal: 8.0),
                child: new Card(
                  elevation: 10.0,
                  child: new Container(
                    child: new Column(
                      crossAxisAlignment: CrossAxisAlignment.center,
                      children: &lt;Widget&gt;[
                        new Text(snapshot.data[index].name, style: TextStyle(fontSize: 18.0),),
                        new Text(snapshot.data[index].msg, style: TextStyle(fontSize: 18.0),),
                        new Text(snapshot.data[index].day, style: TextStyle(fontSize: 18.0),),
                        new Text(snapshot.data[index].date, style: TextStyle(fontSize: 18.0),),
                      ],
                    ),
                  ),
                ),
              ));
            },
          );
        },
      );
    }
  
    @override
    void initState() {
      super.initState();
      fetchPost();
    }
  }
  
  class Post {
    String name;
    String msg;
    String day;
    String date;
  
    Post({this.name, this.msg, this.day, this.date});
  
    factory Post.fromJson(Map&lt;String, dynamic&gt; json) {
      return Post(
        name: json['name'],
        msg: json['msg'],
        day: json['day'],
        date:json['date']
      );
    }
  }
  </code></pre>
  
  <p>How to fix this issue?.<br>
  Thanks in advance.</p>