title: Flutter Error: The body might complete normally, causing 'null' to be returned, but the return type is a potentially non-nullable type
body: <p>I'm using the new dart version &lt;2.13.0-107.0.dev&gt; with null safety enabled.</p>
  <p>With this List of tasks:</p>
  <pre class="lang-dart prettyprint-override"><code>  List&lt;Task&gt; tasks = [
      Task(name: 'find a way to live happy'),
      Task(name: 'Listen to music!!!'),
      Task(name: 'Live in the other world till ur power is off'),
    ];
  </code></pre>
  <p>when I try to use it in a ListView.builder constructor like this:</p>
  <pre class="lang-dart prettyprint-override"><code>  @override
    Widget build(BuildContext context) {
      return ListView.builder(
        itemCount: tasks.length,
        itemBuilder: (context, index) {
           TaskTile(
            taskTitle: tasks[index].name,
            isChecked: tasks[index].isDone,
            checkboxCallback: (bool? checkboxState) {
              setState(() {
  
                tasks[index].toggleDone();
              });
            },
          );
        },
      );
    }
  </code></pre>
  <p>I get this error:</p>
  <p><em><strong>error: The body might complete normally, causing 'null' to be returned, but the return type is a potentially non-nullable type.</strong></em></p>
  <p>and this error in the Run log:</p>
  <p><em><strong>Error: A non-null value must be returned since the return type 'Widget' doesn't allow null.</strong></em></p>
  <p>For more info, the Task class is defined as follows:</p>
  <pre class="lang-dart prettyprint-override"><code>class Task {
    String name;
    bool isDone;
  
    Task({this.name = '', this.isDone = false});
  
    void toggleDone() {
      isDone = !isDone;
    }
  }
  </code></pre>