title: Flutter "this function has a return type of void and cannot be used"
body: <p>I am getting this error: -
  This expression has a type of 'void' so its value can't be used.
  Try checking to see if you're using the correct API; there might be a function or call that returns void you didn't expect. Also check type parameters and variables which might also be void.</p>
  <p>on line number 134 in this code: -</p>
  <pre><code>
  class toDoList extends StatefulWidget
  {
      bool data = false;
      @override
      createState() 
      {
          return new toDoListState();
      }
  }
  
  class toDoListState extends State&lt;toDoList&gt;
  {
    List&lt;String&gt; tasks = [];
    List&lt;String&gt; completedTasks = [];
    List&lt;String&gt; descriptions = [];
    List&lt;bool&gt; importance = [];
    
      @override
      Widget build(BuildContext context)
      {
          return Scaffold
          (
              body: buildToDoList(),
              floatingActionButton: new FloatingActionButton
              (
                  onPressed: addToDoItemScreen, 
                  tooltip: 'Add Task',
                  child: new Icon(Icons.add),
              ),
          );
      }
  
      Widget buildToDoList()
      {
          return new ListView.builder
          (
              itemBuilder: (context, index)
              {
                  if(index &lt; tasks.length)
                  {
                      return row(tasks[index], descriptions[index], index);
                  }
              },
          );
      }
  
      Widget row(String task, String description, int index)
      {                  
          return Dismissible(
          key: UniqueKey(),
          background: Container(color: Colors.red, child: Align(alignment: Alignment.center, child: Text('DELETE', textAlign: TextAlign.center, style: TextStyle(color: Colors.white, fontSize: 18),))),
          direction: DismissDirection.horizontal,
          onDismissed: (direction) {
          setState(() {
            tasks.removeAt(index);
            if(completedTasks.contains(task))
            {
                completedTasks.removeAt(index);
            }
            descriptions.removeAt(index);
            importance.removeAt(index);
          });
            Scaffold.of(context).showSnackBar(SnackBar(content: Text(task+&quot; dismissed&quot;)));
          },
          child: CheckboxListTile(
            controlAffinity: ListTileControlAffinity.leading,
            title: Text(task, style: (completedTasks.contains(task)) ? TextStyle(decoration: TextDecoration.lineThrough) : TextStyle(),),
            subtitle: (importance[index]) ? Text('This is important') : Text('No it\'s not'),
            value: completedTasks.contains(task),
            onChanged: (bool value) {
             setState(() {
                if(!completedTasks.contains(task))
                {
                    completedTasks.add(task);
                }
                else
                {
                    completedTasks.remove(task);
                }
             });
            },
          ));
      }
    
    void addToDoItemScreen() {
      int index = tasks.length;
      while (importance.length &gt; tasks.length) {
        importance.removeLast();
      }
      importance.add(false);
      Navigator.of(context).push(new MaterialPageRoute(builder: (context) {
        return StatefulBuilder(builder: (context, setState) { // this is new
          return new Scaffold(
              appBar: new AppBar(title: new Text('Add a new task')),
              body: Form(
                child: Column(
                  children: &lt;Widget&gt;[
                    TextField(
                      autofocus: true,
                      onSubmitted: (name) {
                        addToDoItem(name);
                        //Navigator.pop(context); // Close the add todo screen
                      },
                      decoration: new InputDecoration(
                          hintText: 'Enter something to do...',
                          contentPadding: const EdgeInsets.all(20.0),
                          border: OutlineInputBorder()),
                    ),
                    TextField(
                      //autofocus: true,
                      onSubmitted: (val) {
                        addDescription(val, index);
                      },
                      decoration: new InputDecoration(
                          hintText: 'Enter a task decription...',
                          contentPadding: const EdgeInsets.all(20.0),
                          border: OutlineInputBorder()),
                    ),
                    Row(
                      children: &lt;Widget&gt; [
                        Switch(
                        value: importance[index],
                        onChanged: (val) {
                          setState(() {
                          });
                          impTask(index);
                        },
                      ),
                      Text('Important Task', style: TextStyle(fontSize: 18)),
                      ],
                    ),
                    RaisedButton(onPressed: Navigator.pop(context),)
                  ],
                ),
              ));
        });
      }));
    }
  
      void addToDoItem(String task)
      {
          setState(() {
            tasks.add(task);
            descriptions.add(&quot;No description&quot;);
          });
      }
  
      void addDescription(String desc, int index)
      {
          setState(() {
            descriptions[index] = desc;
          });
      }
  
      void impTask(int index)
      {
          setState(() {
            if(importance[index])
            {
              importance[index] = false;
            }
            else 
            {
              importance[index] = true;
            }
          });
      }
  }
  </code></pre>
  <p>I don't understand what this is. I am new to flutter. This is my first app. Can someone please help me with this.</p>