title: Flutter - The non-nullable local variable 'newTaskTitle' must be assigned before it can be used
body: <p>Hi so I have been getting this error - &quot;The non-nullable local variable 'newTaskTitle' must be assigned before it can be used. (Documentation)  Try giving it an initializer expression, or ensure that it's assigned on every execution path.&quot; while building my flutter app. I am learning from Angela Yu's udemy course.</p>
  <pre><code>class AddTaskScreen extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      late String newTaskTitle;
      return Container(
        color: const Color(0xff757575),
        child: Container(
          padding: const EdgeInsets.all(25),
          decoration: const BoxDecoration(
            color: Colors.white,
            borderRadius: BorderRadius.only(
              topLeft: Radius.circular(20),
              topRight: Radius.circular(20),
            ),
          ),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.stretch,
            children: [
              const Text(
                'Add task',
                textAlign: TextAlign.center,
                style: TextStyle(color: Colors.lightBlueAccent, fontSize: 30.0),
              ),
              TextField(
                autofocus: true,
                textAlign: TextAlign.center,
                onChanged: (newText) {
                  newTaskTitle = newText;
                },
              ),
              const SizedBox(height: 20),
              TextButton(
                child: const Text(
                  'Add',
                  style: TextStyle(color: Colors.white),
                ),
                style: TextButton.styleFrom(
                  backgroundColor: Colors.lightBlueAccent,
                ),
                onPressed: () {
                  print(newTaskTitle);
                },
              ),
            ],
          ),
        ),
      );
    }
  }
  </code></pre>
  <p>If I set the String newTaskTitle as - late String newTaskTitle</p>
  <pre><code>late String newTaskTitle;
  </code></pre>
  <p>The following error is shown when I print the 'newTaskTitle' variable- &quot;======== Exception caught by gesture ===============================================================
  The following LateError was thrown while handling a gesture:
  LateInitializationError: Local 'newTaskTitle' has not been initialized.&quot;</p>
  <p>This is my first post on stackoverflow so thanks for your help!</p>