marcglasberg / async_redux

Flutter Package: A Redux version tailored for Flutter, which is easy to learn, to use, to test, and has no boilerplate. Allows for both sync and async reducers.
Other
230 stars 41 forks source link

Nullable properties in ViewModel are not fit for `equals` #103

Closed kika closed 3 years ago

kika commented 3 years ago

This doesn't work:

class _ViewM extends Vm {
  final String? error;
  final String name;
  _ViewM({required this.name, this.error}): super(equals: [name, error]);
}

Looking at _listEquals in view_model.dart I don't see anything preventing it from being (List<T?>? list1, List<T?>? list2)

Will PR be accepted or I'm breaking some architectural principles here? (I believe _listEquals just requires the declaration change, but _propsHashCode will need to be guarded against null values

dluksza commented 3 years ago

Have you tried equals: [name, error ?? Null]? This should at least compile, don't know if it will work correctly since I'm still migrating my app to null safety. Hope this helps.

marcglasberg commented 3 years ago

@kika Could you please check if this is fixed for version [9.0.7]?

marcglasberg commented 3 years ago

@kika Closing this, please let me know if the problem is not solved for some reason. Thanks.