hashValues function Null safety

  1. @Deprecated('Use Object.hash() instead. ' 'This feature was deprecated in v3.1.0-0.0.pre.897')
int hashValues(
  1. Object? arg01,
  2. Object? arg02,
  3. [Object? arg03 = _hashEnd,
  4. Object? arg04 = _hashEnd,
  5. Object? arg05 = _hashEnd,
  6. Object? arg06 = _hashEnd,
  7. Object? arg07 = _hashEnd,
  8. Object? arg08 = _hashEnd,
  9. Object? arg09 = _hashEnd,
  10. Object? arg10 = _hashEnd,
  11. Object? arg11 = _hashEnd,
  12. Object? arg12 = _hashEnd,
  13. Object? arg13 = _hashEnd,
  14. Object? arg14 = _hashEnd,
  15. Object? arg15 = _hashEnd,
  16. Object? arg16 = _hashEnd,
  17. Object? arg17 = _hashEnd,
  18. Object? arg18 = _hashEnd,
  19. Object? arg19 = _hashEnd,
  20. Object? arg20 = _hashEnd]
)

Combine up to twenty objects' hash codes into one value.

If you only need to handle one object's hash code, then just refer to its Object.hashCode getter directly.

If you need to combine an arbitrary number of objects from a List or other Iterable, use hashList. The output of hashList can be used as one of the arguments to this function.

For example:

int get hashCode => hashValues(foo, bar, hashList(quux), baz); // ignore: deprecated_member_use

Deprecation

This function has been replaced by Object.hash, so that it can be used outside of Flutter as well. The new function is a drop-in replacement.

The hashList function has also been replaced, Object.hashAll is the new function. The example above therefore is better written as:

int get hashCode => Object.hash(foo, bar, Object.hashAll(quux), baz);

If quux in this example was nullable, then it would need special handling, because Object.hashAll's argument is not nullable:

int get hashCode => Object.hash(foo, bar, quux == null ? null : Object.hashAll(quux), baz);

Implementation

@Deprecated(
  'Use Object.hash() instead. '
  'This feature was deprecated in v3.1.0-0.0.pre.897'
)
int hashValues(
  Object? arg01,            Object? arg02,          [ Object? arg03 = _hashEnd,
  Object? arg04 = _hashEnd, Object? arg05 = _hashEnd, Object? arg06 = _hashEnd,
  Object? arg07 = _hashEnd, Object? arg08 = _hashEnd, Object? arg09 = _hashEnd,
  Object? arg10 = _hashEnd, Object? arg11 = _hashEnd, Object? arg12 = _hashEnd,
  Object? arg13 = _hashEnd, Object? arg14 = _hashEnd, Object? arg15 = _hashEnd,
  Object? arg16 = _hashEnd, Object? arg17 = _hashEnd, Object? arg18 = _hashEnd,
  Object? arg19 = _hashEnd, Object? arg20 = _hashEnd ]) {
  int result = 0;
  result = _Jenkins.combine(result, arg01);
  result = _Jenkins.combine(result, arg02);
  if (!identical(arg03, _hashEnd)) {
    result = _Jenkins.combine(result, arg03);
    if (!identical(arg04, _hashEnd)) {
      result = _Jenkins.combine(result, arg04);
      if (!identical(arg05, _hashEnd)) {
        result = _Jenkins.combine(result, arg05);
        if (!identical(arg06, _hashEnd)) {
          result = _Jenkins.combine(result, arg06);
          if (!identical(arg07, _hashEnd)) {
            result = _Jenkins.combine(result, arg07);
            if (!identical(arg08, _hashEnd)) {
              result = _Jenkins.combine(result, arg08);
              if (!identical(arg09, _hashEnd)) {
                result = _Jenkins.combine(result, arg09);
                if (!identical(arg10, _hashEnd)) {
                  result = _Jenkins.combine(result, arg10);
                  if (!identical(arg11, _hashEnd)) {
                    result = _Jenkins.combine(result, arg11);
                    if (!identical(arg12, _hashEnd)) {
                      result = _Jenkins.combine(result, arg12);
                      if (!identical(arg13, _hashEnd)) {
                        result = _Jenkins.combine(result, arg13);
                        if (!identical(arg14, _hashEnd)) {
                          result = _Jenkins.combine(result, arg14);
                          if (!identical(arg15, _hashEnd)) {
                            result = _Jenkins.combine(result, arg15);
                            if (!identical(arg16, _hashEnd)) {
                              result = _Jenkins.combine(result, arg16);
                              if (!identical(arg17, _hashEnd)) {
                                result = _Jenkins.combine(result, arg17);
                                if (!identical(arg18, _hashEnd)) {
                                  result = _Jenkins.combine(result, arg18);
                                  if (!identical(arg19, _hashEnd)) {
                                    result = _Jenkins.combine(result, arg19);
                                    if (!identical(arg20, _hashEnd)) {
                                      result = _Jenkins.combine(result, arg20);
                                      // I can see my house from here!
                                    }
                                  }
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  return _Jenkins.finish(result);
}