I found out that json_serializable >=4.0.0
depends on json_annotation >=4.0.0 <4.1.0
and the json_annotation: ^4.0.0
includes Null Safety
but json_serializable: ^4.0.2
does not, so the error is occurring.
So I downgraded both packages:
json_annotation: 3.1.1
and
json_serializable: 3.5.1
And they work again properly.