title: The getter 'length' isn't defined for the type 'Future<List<Item>>'
body: <p>I'm writing a kind of todo list in Flutter, with null safety enabled.
  I'm storing the list of todo on a sqlite db using sqflite.</p>
  <p>The Item class is the following:</p>
  <pre><code>class Item {
    int? _id;
    String? _name;
    String? _notes;
    String? _expiryDate;
    int? _category;
    int? _quantity;
    
    Item(
      this._id,
      this._name,
      this._notes,
      this._expiryDate,
      this._category,
      this._quantity,
    );
  
    // names for db table and columns
    String tableItems = 'items';
    String colId = 'id';
    String colName = 'name';
    String colNotes = 'notes';
    String colExpiryDate = 'expiryDate';
    String colCategory = 'category';
    String colQuantity = 'quantity';
    
    // Getters
    int? get id =&gt; _id;
    String? get name =&gt; _name;
    String? get notes =&gt; _notes;
    String? get expiryDate =&gt; _expiryDate;
    int? get category =&gt; _category;
    int? get quantity =&gt; _quantity;
  
    // Imports the Item details from a map
    Item.fromMap(Map map) {
      this._id = map[colId];
      this._name = map[colName];
      this._notes = map[colNotes];
      this._expiryDate = map[colExpiryDate];
      this._category = map[colCategory];
      this._quantity = map[colQuantity];
    }
  
    // Converts a Item into a Map
    Map&lt;String, dynamic&gt; toMap() {
      var map = Map&lt;String, dynamic&gt;();
      map['id'] = _id;
      map['name'] = _name;
      map['notes'] = _notes;
      map['expiryDate'] = _expiryDate;
      map['category'] = _category;
      map['quantity'] = _quantity;
      return map;
    }
  
    // Implement toString to make it easier to see information about
    // each dog when using the print statement.
    @override
    String toString() {
      return 'Item{id: $_id, name: $_name, notes: $_notes, expiryDate: $_expiryDate, category: $_category, quantity: $_quantity}';
    }
    
  }
  </code></pre>
  <p>I have a class named items_controller which works as an intermediary between the Item class and the db_controller class.
  This is the items_controller class:</p>
  <pre><code>import 'package:get/get.dart';
  import 'package:&lt;redacted&gt;/model/item.dart';
  
  import 'db_controller.dart';
  
  class ItemsController extends GetxController {
    // names for db table and columns
    String tableItems = 'items';
    String colId = 'id';
    String colName = 'name';
    String colNotes = 'notes';
    String colExpiryDate = 'expiryDate';
    String colCategory = 'category';
    String colQuantity = 'quantity';
  
    //TODO
    void loadItem() {}
  
    // function to retrieve all the items from the db
    Future&lt;List&lt;Item&gt;&gt; loadAllItems() async {
      final dbController = DBController();
      final List&lt;Map&lt;String, dynamic&gt;&gt; itemsMaps =
          await dbController.query(tableItems);
  
      return List.generate(itemsMaps.length, (i) {
        return Item.fromMap(itemsMaps[i]);
      });
    }
  
    // function to add an item to the db
    Future&lt;int&gt; addItem(Item item) async {
      final dbController = DBController();
      // add a new Item to the table and get the id
      int id = await dbController.insertElement(tableItems, item);
      return id;
    }
  
    //TODO
    void updateItem() {}
  
    //TODO
    void deleteItem(int index) {}
  }
  </code></pre>
  <p>Given that, from the list_builder (which uses the ListView.builder method) I want to build a list using as index the length of the list of Items queried from the DB.
  But I have this error (as in title)
  [![screenshot][1]][1]
  [1]: https://i.stack.imgur.com/Z6VAh.png</p>
  <p>I'm quite sure that the Future&lt;List&gt; that I'm getting when calling loadAllItems() should have a <strong>length</strong> property because it's a list, but I'm not sure, maybe because it's a Future List?
  Help please!</p>
  <p><strong>EDIT</strong>
  I've implemented the FutureBuilder, but I had no luck with the .length attribute:
  [![snapshot][2]][2]
  [2]: https://i.stack.imgur.com/QswA0.png</p>
  <p>If I run anyway the code, I get the following errors:</p>
  <pre><code>Performing hot restart...
  Syncing files to device AC2003...
  lib/views/list_builder.dart:21:45: Error: The getter 'length' isn't defined for the class 'Object'.
   - 'Object' is from 'dart:core'.
  Try correcting the name to the name of an existing getter, or defining a getter or field named 'length'.
                    itemCount: snapshot.data!.length,
                                              ^^^^^^
  lib/views/list_builder.dart:16:20: Error: A non-null value must be returned since the return type 'Widget' doesn't allow null.
   - 'Widget' is from 'package:flutter/src/widgets/framework.dart' ('../../flutter/packages/flutter/lib/src/widgets/framework.dart').
            builder: (context, snapshot) {
                     ^
  Restarted application in 671ms.
  </code></pre>