I am using an extension for creating flutter class and I want to use equatable with it but it seem like it doesn't support nullable, is there a way to use it or do I have to use the generate equatable that the extension provide.
Asked
Active
Viewed 233 times
1

Md. Yeasin Sheikh
- 54,221
- 7
- 29
- 56

Ken
- 57
- 6
-
Avoid positing code-image, include code-snippet, find more about [how-to-ask](https://stackoverflow.com/help/how-to-ask) a good question – Md. Yeasin Sheikh Aug 27 '22 at 04:32
2 Answers
3
props
accept nullable data, change like
List<Object?> get props => [];

Md. Yeasin Sheikh
- 54,221
- 7
- 29
- 56
-
A comment above did something similar does it work if I don't have the value ? – Ken Aug 27 '22 at 04:14
-
As the question seek if the props accept nullable data or not, so the answer is yes it accept nullable data. You've need to put your prop inside `[]` and you already know it. Check the link for the source code to prove that it actually accept null data. – Md. Yeasin Sheikh Aug 27 '22 at 04:31
1
you problem is in List<Object>
which is not using ?
, try this:
@override
List<Object?> get props => [name, surename];

eamirho3ein
- 16,619
- 2
- 12
- 23
-
But does it affect the equatable package, because I don't think they allow nullable – Ken Aug 27 '22 at 04:13
-
the package said that if you are using variable which might be null, you this approach. – eamirho3ein Aug 27 '22 at 06:26