hashCodeImpl function Null safety

String hashCodeImpl(
  1. List<String> fieldNames
)

Implementation

String hashCodeImpl(List<String> fieldNames) {
  if (fieldNames.isEmpty) {
    return '''@override
      int get hashCode => 0;
    ''';
  }
  const result = r'__result$';
  final updates =
      fieldNames.map((name) => '$result = 37 * $result + this.$name.hashCode;').join('\n');
  return '''@override
    int get hashCode {
      var $result = 17;
      $updates
      return $result;
    }''';
}