Skip to content

Commit b872ed1

Browse files
committed
Format, update rules, jonah review
1 parent e438d32 commit b872ed1

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

packages/vector_graphics_compiler/lib/src/geometry/matrix.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,15 +172,16 @@ class AffineMatrix {
172172
}
173173

174174
@override
175-
int get hashCode => Object.hash(a, b, c, d, e, f);
175+
int get hashCode => Object.hash(a, b, c, d, e, f, _m4_10);
176176

177177
@override
178178
bool operator ==(Object other) {
179179
return other is AffineMatrix &&
180180
other.a == a &&
181181
other.b == b &&
182182
other.d == d &&
183-
other.e == e;
183+
other.e == e &&
184+
other._m4_10 == _m4_10;
184185
}
185186

186187
@override

packages/vector_graphics_compiler/lib/src/geometry/path.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import 'dart:math' as math;
2-
31
import 'package:meta/meta.dart';
42
import 'package:path_parsing/path_parsing.dart';
53

64
import 'basic_types.dart';
75
import 'matrix.dart';
86
import '../util.dart';
97

8+
// This is a magic number used by impeller for radius approximation:
9+
// https://github.com/flutter/impeller/blob/a2478aa4939a9a08c6c3810f72e0db42e7383a07/geometry/path_builder.cc#L9
10+
// See https://spencermortensen.com/articles/bezier-circle/ for more information.
1011
const double _kArcApproximationMagic = 0.551915024494;
1112

1213
/// Specifies the winding rule that decies how the interior of a [Path] is

packages/vector_graphics_compiler/test/basic_types_test.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import 'package:vector_graphics_compiler/vector_graphics_compiler.dart';
33
import 'package:test/test.dart';
44

55
void main() {
6-
test('Point tests', () {
6+
test('Point tests', () {
77
expect(Point.zero.x, 0);
88
expect(Point.zero.y, 0);
99

@@ -18,8 +18,9 @@ void main() {
1818
expect(Rect.zero.bottom, 0);
1919

2020
expect(
21-
const Rect.fromLTRB(1, 2, 3, 4).expanded(const Rect.fromLTRB(0, 0, 10, 10)),
22-
const Rect.fromLTRB(0, 0, 10 ,10),
21+
const Rect.fromLTRB(1, 2, 3, 4)
22+
.expanded(const Rect.fromLTRB(0, 0, 10, 10)),
23+
const Rect.fromLTRB(0, 0, 10, 10),
2324
);
2425

2526
expect(

packages/vector_graphics_compiler/test/matrix_test.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,12 @@ void main() {
9696
expect(rotatedRect.right + 20, lessThan(epsillon));
9797
expect(rotatedRect.bottom - 30, lessThan(epsillon));
9898
});
99+
100+
test('== and hashCode account for hidden field', () {
101+
const AffineMatrix matrixA = AffineMatrix.identity;
102+
const AffineMatrix matrixB = AffineMatrix(1, 0, 0, 1, 0, 0, 0);
103+
104+
expect(matrixA != matrixB, true);
105+
expect(matrixA.hashCode != matrixB.hashCode, true);
106+
});
99107
}

0 commit comments

Comments
 (0)