title: How to check if JSON array is empty in Flutter
body: <p>Trying to create an if statement that checks if an API returns 'items' containing data</p>
  <p>Here is the API url, you can see that items is empty for that specific data query <a href="https://data.food.gov.uk/food-alerts/id?since=2021-01-04T00:00:00Z" rel="nofollow noreferrer">https://data.food.gov.uk/food-alerts/id?since=2021-01-04T00:00:00Z</a></p>
  <p>My code is below, been trying to see if I can check 'items' to see if it is null, as well as checking for its length and see if it equals 0 but has not worked so far</p>
  <pre><code>class AllergyAlert {
    final String title;
  
    AllergyAlert({this.title});
  
    factory AllergyAlert.fromJson(Map&lt;String, dynamic&gt; json) {
      if (json['items'] == null) {
        return AllergyAlert(
          title: 'No new allergy alerts',
        );
      } else {
        return AllergyAlert(
          title: json['items'][0]['title'],
        );
      }
    }
  }
  
  </code></pre>