title: error: The method 'setState' isn't defined for the type 'TasksScreen'. (undefined_method at [todoey] lib/screens/tasks_screen.dart:26)
body: <p>So I am trying to use a callback to add a task to my task list. But I am unable to access setState() in my callback function.
  Let me explain,</p>
  <p>This is my add_task_screen, that contains my modalBottomSheet.</p>
  <pre><code>import 'package:flutter/cupertino.dart';
  import 'package:flutter/material.dart';
  
  class AddTaskScreen extends StatelessWidget {
  
    String newTaskText;
    final Function addNewTask;
    AddTaskScreen({@required this.addNewTask});
  
    @override
    Widget build(BuildContext context) {
      return SingleChildScrollView(
        child: Padding(
          padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
          child: Container(
            color: Color(0xFF757575),
            child: Container(
              decoration: BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.only(
                  topLeft: Radius.circular(20.0),
                  topRight: Radius.circular(20.0),
                )
              ),
              child: Padding(
                padding: EdgeInsets.symmetric(horizontal: 65.0),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.stretch,
                  children: &lt;Widget&gt;[
                    Padding(
                      padding: EdgeInsets.only(top: 15.0),
                      child: Text(
                        'Add Task',
                        textAlign: TextAlign.center,
                        style: TextStyle(
                          color: Colors.lightBlueAccent,
                          fontSize: 30.0
                        ),
                      ),
                    ),
                    TextField(
                      style: TextStyle(fontSize: 22.0 ),
                      autofocus: true,
                      textAlign: TextAlign.center,
                      onChanged: (value) {
                        newTaskText = value;
                      },
                    ),
                    SizedBox(
                      height: 15.0,
                    ),
                    FlatButton(
                      color: Colors.lightBlueAccent,
                      child: Text(
                        'Add',
                        style: TextStyle(
                          color: Colors.white,
                          fontSize: 20.0,
                        ),
                      ),
                      onPressed: () {
                        addNewTask(newTaskText);
                      },
                    )
                  ],
                ),
              ),
            ),
          ),
        ),
      );
    }
  }
  </code></pre>
  <p>So here when, I click on 'Add', I want to add my task in my task-list. but using a callback, just to update other parts of my App. So I am using the callback in tasks_screen which is the parent of the add_tasks page.
  Here is my tasks_screen page,</p>
  <pre><code>import 'package:flutter/material.dart';
  import 'package:todoey/widgets/tasks_list.dart';
  import 'package:todoey/screens/add_task_screen.dart';
  import 'package:todoey/models/task.dart';
  
  class TasksScreen extends StatelessWidget {
  
    List&lt;Task&gt; tasks = [];
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        backgroundColor: Colors.lightBlueAccent,
        floatingActionButton: FloatingActionButton(
          backgroundColor: Colors.lightBlueAccent,
          child: Icon(Icons.add, size: 40.0),
          onPressed: () {
            showModalBottomSheet(
              context: context,
              builder: (context) =&gt; AddTaskScreen(
                addNewTask: (String newTaskText) {
  
                  print(newTaskText);
                  tasks.add(Task(taskText: newTaskText));
                  
  // FIXME: Some issue here...
                  setState(() {
                    tasks.add(Task(taskText: newTaskText));
                  });
                  Navigator.pop(context);
  
                },
              ),
              isScrollControlled: true
            );
          },
        ),
        body: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: &lt;Widget&gt;[
            Container(
              padding: EdgeInsets.only(top: 60.0, left: 30, right: 30.0, bottom: 30.0),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: &lt;Widget&gt;[
                  CircleAvatar(
                    child: Icon(Icons.list, size: 30.0, color: Colors.lightBlueAccent,),
                    backgroundColor: Colors.white,
                    radius: 30.0,
                  ),
                  SizedBox(
                    height: 10.0,
                  ),
                  Text(
                    'Todoey',
                    style: TextStyle(
                      color: Colors.white,
                      fontSize: 50.0,
                      fontWeight: FontWeight.w700,
                    ),
                  ),
                  Text(
                    '12 Tasks',
                    style: TextStyle(
                      color: Colors.white,
                      fontSize: 18.0,
                    ),
                  ),
                ],
              ),
            ),
            Expanded(
              child: Container(
                padding: EdgeInsets.symmetric(horizontal: 20.0),
                decoration: BoxDecoration(
                  color: Colors.white,
                  borderRadius: BorderRadius.only(
                      topRight: Radius.circular(20.0),
                      topLeft: Radius.circular(20.0)
                  ),
                ),
                child: TasksList(tasks: tasks),
              ),
            ),
          ],
        ),
      );
    }
  }
  
  </code></pre>
  <p>So I am getting an error on the setState() under the FIXME comment. The error is the title of the question. So the irony here is the task is getting printed, in my console. But when I am trying to change state to add a task in my tasks list and then pop off the bottomSheet, I am getting an error.
  Note: Task is a model.</p>
  <p>Please someone tell me how to fix this. Thanks in advance.</p>