title: The getter 'length' was called on null. Receiver: null Tried calling: length FutureBuilder with List
body: <p>I keep getting the error mentioned above during runtime of my flutter app. Basically what I am trying to achieve is to fetch data from an api and display it in a form of a SliverList by using a FutureBuilder.</p>
  <p>This was working perfectly fine until I changed my code for the list from FutureBuilder&lt;List&gt; to FutureBuilder&lt;List&gt; to make use of the class EntertainerEvent which has all the fields I need for display from the json file.
  How can I resolve this because it seems like the contructor or the application itslef is not picking up the data when I make use of a custom class.</p>
  <p>This is the code for the EntertainerEvent class:</p>
  <pre><code>    class EntertainerEvent {
        final int eventId;
        final int entertainerId;
        final int eventTypeId;
        final int categoryId;
        final String eventName;
        final String description;
        final String imagePoster;
        final String location;
        final DateTime startDate;
        final DateTime endDate;
        final double entreeFee;
      
        const EntertainerEvent({required this.eventId, required this.entertainerId, required this.eventTypeId,
          required this.categoryId, required this.eventName, required this.description, required this.imagePoster,
          required this.location, required this.startDate, required this.endDate, required this.entreeFee});
      
        factory EntertainerEvent.fromJson(Map&lt;String, dynamic&gt; event) {
          return EntertainerEvent(
            eventId: event['EventID'],
            entertainerId: event['EntertainerID'],
            eventTypeId: event['EventTypeID'],
            categoryId: event['CategoryID'],
            eventName: event['EventName'],
            description: event['Description'],
            imagePoster: event['ImagePoster'],
            location: event['Location'],
            startDate: event['StartDate'],
            endDate: event['EndDate'],
            entreeFee: event['EntryFee'],
          );
        }
      }
  </code></pre>
  <p>Below is the code for fetching data from the api:</p>
  <pre><code>
  Future&lt;List&lt;EntertainerEvent&gt;&gt; fetchEvents() async {
      var result = await http.get(Uri.parse(apiUrl));
  
      if (result.statusCode == 200) {
        var content = result.body;
        var arr = json.decode(content) as List;
  
        return arr.map((eve) =&gt; new EntertainerEvent.fromJson(eve)).toList();
      } else {
        print('Not loaded');
        throw Exception('Unable to fetch data from the Rest API');
      }
    }
  
    late Future&lt;List&lt;EntertainerEvent&gt;&gt; _fetchEvents;
  
    @override
    void initState() {
      _fetchEvents = fetchEvents();
      super.initState();
    }
  
    @override
    Widget build(BuildContext context) {
      return FutureBuilder&lt;List&lt;EntertainerEvent&gt;&gt;(
          future: _fetchEvents,
          builder: (BuildContext context, AsyncSnapshot snapshot) {
            var childCount = 0;
            if (snapshot.connectionState != ConnectionState.done) {
              childCount = 1;
            } else {
              childCount = snapshot.data.length;
            }
            return SliverList(
              delegate: SliverChildBuilderDelegate((context, index) {
                if (snapshot.hasData) {
                  List&lt;EntertainerEvent&gt; someData = snapshot.data;
                  print('data here');
                 
                  //Do some stuff
  
                 }
                },  childCount: childCount),
             );
         });
    }
  </code></pre>
  <p>I do not know what exactly is it that I am missing because this code works if I use the type dynamic instead of the custom class EntertainerEvent.</p>
  <p>Thank you all in advance!</p>