comparer 1.0.0 copy "comparer: ^1.0.0" to clipboard
comparer: ^1.0.0 copied to clipboard

outdated

A Dart package that helps to implement value based equality without needing to explicitly override == and hashCode.

example/main.dart

import 'package:comparer/comparer.dart';

void main() {
  var one = TestOne(
    1,
    "2",
    <Object>[3, "4", 5.5],
    <String, Object>{"6": 6, "7": "7", "8": 8.8},
  );
  var two = TestOne(
    1,
    "2",
    <Object>[3, "4", 5.5],
    <String, Object>{"6": 6, "7": "7", "8": 8.8},
  );
  print(one);
  print(one == two);
  print(one.hashCode == two.hashCode);
}

class TestOne extends ComparerList {
  TestOne(this.v1, this.v2, this.v3, this.v4);

  final int v1;
  final String v2;
  final List<Object> v3;
  final Map<String, Object> v4;

  @override
  List<Object> get equals => [v1, v2, v3, v4];
}

class TestTwo extends ComparerMap {
  TestTwo(this.v1, this.v2, this.v3, this.v4);

  final int v1;
  final String v2;
  final List<Object> v3;
  final Map<String, Object> v4;

  @override
  Map<String, Object> get equals => {
        "v1": v1,
        "v2": v2,
        "v3": v3,
        "v4": v4,
      };
}
1
likes
0
pub points
60%
popularity

Publisher

unverified uploader

A Dart package that helps to implement value based equality without needing to explicitly override == and hashCode.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

collection, meta

More

Packages that depend on comparer