title: Why is my RaisedButton not working in Flutter?
body: <p>I have been working on a to-do list app in Flutter but in the process, I realized that the add button was not working when it was supposed to add a new task. I don't know why it doesn't work, because I am very new to Flutter. Why is this problem occurring!?</p>
  <p>main.dart</p>
  <pre><code>  List&lt;String&gt; _toDoItems = [];
  
    void _addToDoItem(String task) {
      if(task.length &gt; 0) {
        setState(() {  
          _toDoItems.add(task);
        });
      }
    }
    Expanded(
      flex: 8,
      child: TextField(
        autofocus: true,
        onSubmitted: (val) {
          _addToDoItem(val);
        },
      ),
    ),
    Expanded(
      flex: 2,
        child: RaisedButton(
          child: Text('ADD'),
            onPressed: () =&gt; _addToDoItem,
        ),
    ),
  </code></pre>