Home > front end >  The non-nullable local variable 'newTaskTitle' must be assigned before it can be used
The non-nullable local variable 'newTaskTitle' must be assigned before it can be used

Time:12-01

enter image description hereenter image description here

I'm Trying to capture onChanged property value which is comming from my TextField and use it inside my onPressed textButton but it's not working. I've read most of the related issues in stack overflow but none of it actually helping in the problem. Do you have any better suggestion that I should do.

CodePudding user response:

You have not initialized newTaskTile before accessing it. So, at line 12 instead of:

String newTaskTile;

use:

String newTaskTile='';

CodePudding user response:

You can use

    late String? newTaskTile;

and assign a value on init

  @override
  void initState() {
    super.initState();
    newTaskTile = 'some value';
  }
  • Related