jankuss / genq

Instant Data Class Generation for Dart
MIT License
133 stars 0 forks source link

Hash code gen bug: Too many positional arguments #34

Closed BWhiteApps closed 3 months ago

BWhiteApps commented 3 months ago

The hashcode function that gets generated cannot handle more than 20 arguments. Therefore once a class reaches over 20 properties this error occurs:

Error: Too many positional arguments: 20 allowed, but 21 found.
Try removing the extra positional arguments.
    return Object.hash(
                      ^
org-dartlang-sdk:///third_party/dart/sdk/lib/core/object.dart:183:14: Context: Found this candidate, but the arguments don't match.
  static int hash(Object? object1, Object? object2,

The way to fix this is to use

@override
int get hashCode => Object.hashAll([ <List of properties> ]);

instead of

@override
int get hashCode => Object.hash(<List of properties>);
jankuss commented 3 months ago

Fixed in 0.5.0

brew upgrade jankuss/genq/genq