Warning: Operand of null-aware operation '??' has type 'String' which excludes null

Viewed 3269

I have the below 2 line code . I do say the controllers can be null in initialisation. And if it is null, take empty string. So why would it throw this error ?

final List<String>? controllers;
_nameController.text = widget.controllers[widget.index] ?? '';
1 Answers

Try declaring like this:

final List<String?> controllers;
Related