'The argument type 'void Function(int)' can't be assigned to the parameter type 'void Function(int?)?' [closed]

Hello for all I have problem so I want to best solution for this code enter image description here

It shows The argument type

'void Function(int)' can't be assigned to the parameter type 'void Function(int?)?'.



Solution 1:[1]

Update:

(int newColor) {...}

to

(int? newColor) {...}

Solution 2:[2]

This is null safety error

define color variable like this:

int? color;

also change the following lines to this:

int? newColor;
saveColor(newColor!);

for more info about null safety: https://dart.dev/null-safety

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Apealed
Solution 2