Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
e78d6cbc
Commit
e78d6cbc
authored
Dec 12, 2015
by
Ian Hickson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #857 from Hixie/hashCodes
Use hashValues instead of hard-coded hashCode getters
parents
1ab83e66
d8a3ed3e
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
61 additions
and
172 deletions
+61
-172
stock_row.dart
examples/stocks/lib/stock_row.dart
+1
-1
theme_data.dart
packages/flutter/lib/src/material/theme_data.dart
+14
-14
time_picker.dart
packages/flutter/lib/src/material/time_picker.dart
+1
-6
basic_types.dart
packages/flutter/lib/src/painting/basic_types.dart
+3
-1
box_painter.dart
packages/flutter/lib/src/painting/box_painter.dart
+16
-85
colors.dart
packages/flutter/lib/src/painting/colors.dart
+2
-9
edge_dims.dart
packages/flutter/lib/src/painting/edge_dims.dart
+2
-8
text_painter.dart
packages/flutter/lib/src/painting/text_painter.dart
+1
-7
text_style.dart
packages/flutter/lib/src/painting/text_style.dart
+14
-15
box.dart
packages/flutter/lib/src/rendering/box.dart
+2
-6
stack.dart
packages/flutter/lib/src/rendering/stack.dart
+2
-9
framework.dart
packages/flutter/lib/src/widgets/framework.dart
+1
-0
mixed_viewport.dart
packages/flutter/lib/src/widgets/mixed_viewport.dart
+1
-1
page_storage.dart
packages/flutter/lib/src/widgets/page_storage.dart
+1
-10
No files found.
examples/stocks/lib/stock_row.dart
View file @
e78d6cbc
...
...
@@ -21,7 +21,7 @@ class StockRowPartKey extends Key {
&&
stock
==
typedOther
.
stock
&&
part
==
typedOther
.
part
;
}
int
get
hashCode
=>
37
*
(
37
*
(
37
*
(
373
)
+
identityHashCode
(
keySalt
))
+
identityHashCode
(
stock
))
+
identityHashCode
(
part
);
int
get
hashCode
=>
hashValues
(
keySalt
,
stock
,
part
);
String
toString
()
=>
'[
$runtimeType
${keySalt.toString().split(".")[1]}
:
${stock.symbol}
:
${part.toString().split(".")[1]}
]'
;
}
...
...
packages/flutter/lib/src/material/theme_data.dart
View file @
e78d6cbc
...
...
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:ui'
show
Color
;
import
'dart:ui'
show
Color
,
hashValues
;
import
'colors.dart'
;
import
'icon_theme_data.dart'
;
...
...
@@ -153,19 +153,19 @@ class ThemeData {
(
otherData
.
accentColorBrightness
==
accentColorBrightness
);
}
int
get
hashCode
{
int
value
=
373
;
value
=
37
*
value
+
brightness
.
hashCode
;
value
=
37
*
value
+
primarySwatch
.
hashCode
;
value
=
37
*
value
+
canvasColor
.
hashCode
;
value
=
37
*
value
+
cardColor
.
hashCode
;
value
=
37
*
value
+
dividerColor
.
hashCode
;
value
=
37
*
value
+
hintColor
.
hashCode
;
value
=
37
*
value
+
highlightColor
.
hashCode
;
value
=
37
*
value
+
hintOpacity
.
hashCode
;
value
=
37
*
value
+
text
.
hashCode
;
value
=
37
*
value
+
primaryColorBrightness
.
hashCode
;
value
=
37
*
value
+
accentColorBrightness
.
hashCode
;
return
value
;
return
hashValues
(
brightness
,
primarySwatch
,
canvasColor
,
cardColor
,
dividerColor
,
hintColor
,
highlightColor
,
hintOpacity
,
text
,
primaryColorBrightness
,
accentColorBrightness
)
;
}
String
toString
()
=>
'
$primaryColor
$brightness
etc...'
;
...
...
packages/flutter/lib/src/material/time_picker.dart
View file @
e78d6cbc
...
...
@@ -84,12 +84,7 @@ class TimeOfDay {
&&
typedOther
.
minute
==
minute
;
}
int
get
hashCode
{
int
value
=
373
;
value
=
37
*
value
+
hour
.
hashCode
;
value
=
37
*
value
+
minute
.
hashCode
;
return
value
;
}
int
get
hashCode
=>
hashValues
(
hour
,
minute
);
// TODO(ianh): Localize.
String
toString
()
=>
'
$hourOfPeriodLabel
:
$minuteLabel
$periodLabel
'
;
...
...
packages/flutter/lib/src/painting/basic_types.dart
View file @
e78d6cbc
...
...
@@ -18,4 +18,6 @@ export 'dart:ui' show
TextBaseline
,
TextDecoration
,
TextDecorationStyle
,
VoidCallback
;
VoidCallback
,
hashValues
,
hashList
;
packages/flutter/lib/src/painting/box_painter.dart
View file @
e78d6cbc
...
...
@@ -39,12 +39,7 @@ class BorderSide {
width
==
typedOther
.
width
;
}
int
get
hashCode
{
int
value
=
373
;
value
=
37
*
value
+
color
.
hashCode
;
value
=
37
*
value
+
width
.
hashCode
;
return
value
;
}
int
get
hashCode
=>
hashValues
(
color
,
width
);
String
toString
()
=>
'BorderSide(
$color
,
$width
)'
;
}
...
...
@@ -96,14 +91,7 @@ class Border {
left
==
typedOther
.
left
;
}
int
get
hashCode
{
int
value
=
373
;
value
=
37
*
value
+
top
.
hashCode
;
value
=
37
*
value
+
right
.
hashCode
;
value
=
37
*
value
+
bottom
.
hashCode
;
value
=
37
*
value
+
left
.
hashCode
;
return
value
;
}
int
get
hashCode
=>
hashValues
(
top
,
right
,
bottom
,
left
);
String
toString
()
=>
'Border(
$top
,
$right
,
$bottom
,
$left
)'
;
}
...
...
@@ -199,14 +187,7 @@ class BoxShadow {
spreadRadius
==
typedOther
.
spreadRadius
;
}
int
get
hashCode
{
int
value
=
373
;
value
=
37
*
value
+
color
.
hashCode
;
value
=
37
*
value
+
offset
.
hashCode
;
value
=
37
*
value
+
blurRadius
.
hashCode
;
value
=
37
*
value
+
spreadRadius
.
hashCode
;
return
value
;
}
int
get
hashCode
=>
hashValues
(
color
,
offset
,
blurRadius
,
spreadRadius
);
String
toString
()
=>
'BoxShadow(
$color
,
$offset
,
$blurRadius
,
$spreadRadius
)'
;
}
...
...
@@ -282,25 +263,7 @@ class LinearGradient extends Gradient {
return
true
;
}
int
get
hashCode
{
int
value
=
373
;
value
=
37
*
value
+
begin
.
hashCode
;
value
=
37
*
value
+
end
.
hashCode
;
value
=
37
*
value
+
tileMode
.
hashCode
;
if
(
colors
!=
null
)
{
for
(
int
i
=
0
;
i
<
colors
.
length
;
i
+=
1
)
value
=
37
*
value
+
colors
[
i
].
hashCode
;
}
else
{
value
=
37
*
value
+
null
.
hashCode
;
}
if
(
stops
!=
null
)
{
for
(
int
i
=
0
;
i
<
stops
.
length
;
i
+=
1
)
value
=
37
*
value
+
stops
[
i
].
hashCode
;
}
else
{
value
=
37
*
value
+
null
.
hashCode
;
}
return
value
;
}
int
get
hashCode
=>
hashValues
(
begin
,
end
,
tileMode
,
hashList
(
colors
),
hashList
(
stops
));
String
toString
()
{
return
'LinearGradient(
$begin
,
$end
,
$colors
,
$stops
,
$tileMode
)'
;
...
...
@@ -374,25 +337,7 @@ class RadialGradient extends Gradient {
return
true
;
}
int
get
hashCode
{
int
value
=
373
;
value
=
37
*
value
+
center
.
hashCode
;
value
=
37
*
value
+
radius
.
hashCode
;
value
=
37
*
value
+
tileMode
.
hashCode
;
if
(
colors
!=
null
)
{
for
(
int
i
=
0
;
i
<
colors
.
length
;
i
+=
1
)
value
=
37
*
value
+
colors
[
i
].
hashCode
;
}
else
{
value
=
37
*
value
+
null
.
hashCode
;
}
if
(
stops
!=
null
)
{
for
(
int
i
=
0
;
i
<
stops
.
length
;
i
+=
1
)
value
=
37
*
value
+
stops
[
i
].
hashCode
;
}
else
{
value
=
37
*
value
+
null
.
hashCode
;
}
return
value
;
}
int
get
hashCode
=>
hashValues
(
center
,
radius
,
tileMode
,
hashList
(
colors
),
hashList
(
stops
));
String
toString
()
{
return
'RadialGradient(
$center
,
$radius
,
$colors
,
$stops
,
$tileMode
)'
;
...
...
@@ -582,12 +527,7 @@ class FractionalOffset {
return
x
==
typedOther
.
x
&&
y
==
typedOther
.
y
;
}
int
get
hashCode
{
int
value
=
373
;
value
=
37
*
value
+
x
.
hashCode
;
value
=
37
*
value
+
y
.
hashCode
;
return
value
;
}
int
get
hashCode
=>
hashValues
(
x
,
y
);
static
FractionalOffset
lerp
(
FractionalOffset
a
,
FractionalOffset
b
,
double
t
)
{
if
(
a
==
null
&&
b
==
null
)
return
null
;
...
...
@@ -688,16 +628,7 @@ class BackgroundImage {
_imageResource
==
typedOther
.
_imageResource
;
}
int
get
hashCode
{
int
value
=
373
;
value
=
37
*
value
+
fit
.
hashCode
;
value
=
37
*
value
+
repeat
.
hashCode
;
value
=
37
*
value
+
centerSlice
.
hashCode
;
value
=
37
*
value
+
colorFilter
.
hashCode
;
value
=
37
*
value
+
alignment
.
hashCode
;
value
=
37
*
value
+
_imageResource
.
hashCode
;
return
value
;
}
int
get
hashCode
=>
hashValues
(
fit
,
repeat
,
centerSlice
,
colorFilter
,
alignment
,
_imageResource
);
String
toString
()
=>
'BackgroundImage(
$fit
,
$repeat
)'
;
}
...
...
@@ -850,15 +781,15 @@ class BoxDecoration extends Decoration {
}
int
get
hashCode
{
int
value
=
373
;
value
=
37
*
value
+
backgroundColor
.
hashCode
;
value
=
37
*
value
+
backgroundImage
.
hashCode
;
value
=
37
*
value
+
border
.
hashCode
;
value
=
37
*
value
+
borderRadius
.
hashCode
;
value
=
37
*
value
+
boxShadow
.
hashCode
;
value
=
37
*
value
+
gradient
.
hashCode
;
value
=
37
*
value
+
shape
.
hashCode
;
return
value
;
return
hashValues
(
backgroundColor
,
backgroundImage
,
border
,
borderRadius
,
boxShadow
,
gradient
,
shape
)
;
}
String
toString
([
String
prefix
=
''
])
{
...
...
packages/flutter/lib/src/painting/colors.dart
View file @
e78d6cbc
...
...
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:ui'
show
Color
,
lerpDouble
;
import
'dart:ui'
show
Color
,
lerpDouble
,
hashValues
;
class
HSVColor
{
const
HSVColor
.
fromAHSV
(
this
.
alpha
,
this
.
hue
,
this
.
saturation
,
this
.
value
);
...
...
@@ -113,14 +113,7 @@ class HSVColor {
&&
typedOther
.
value
==
value
;
}
int
get
hashCode
{
int
value
=
373
;
value
=
37
*
value
+
alpha
.
hashCode
;
value
=
37
*
value
+
hue
.
hashCode
;
value
=
37
*
value
+
saturation
.
hashCode
;
value
=
37
*
value
+
value
.
hashCode
;
return
value
;
}
int
get
hashCode
=>
hashValues
(
alpha
,
hue
,
saturation
,
value
);
String
toString
()
=>
"HSVColor(
$alpha
,
$hue
,
$saturation
,
$value
)"
;
}
packages/flutter/lib/src/painting/edge_dims.dart
View file @
e78d6cbc
...
...
@@ -3,6 +3,7 @@
// found in the LICENSE file.
import
'dart:ui'
as
ui
;
import
'dart:ui'
show
hashValues
;
/// An immutable set of offsets in each of the four cardinal directions.
///
...
...
@@ -136,14 +137,7 @@ class EdgeDims {
left
==
typedOther
.
left
;
}
int
get
hashCode
{
int
value
=
373
;
value
=
37
*
value
+
top
.
hashCode
;
value
=
37
*
value
+
left
.
hashCode
;
value
=
37
*
value
+
bottom
.
hashCode
;
value
=
37
*
value
+
right
.
hashCode
;
return
value
;
}
int
get
hashCode
=>
hashValues
(
top
,
left
,
bottom
,
right
);
String
toString
()
=>
"EdgeDims(
$top
,
$right
,
$bottom
,
$left
)"
;
}
packages/flutter/lib/src/painting/text_painter.dart
View file @
e78d6cbc
...
...
@@ -78,13 +78,7 @@ class StyledTextSpan extends TextSpan {
return
true
;
}
int
get
hashCode
{
int
value
=
373
;
value
=
37
*
value
+
style
.
hashCode
;
for
(
TextSpan
child
in
children
)
value
=
37
*
value
+
child
.
hashCode
;
return
value
;
}
int
get
hashCode
=>
hashValues
(
style
,
hashList
(
children
));
String
toString
([
String
prefix
=
''
])
{
List
<
String
>
result
=
<
String
>[];
...
...
packages/flutter/lib/src/painting/text_style.dart
View file @
e78d6cbc
...
...
@@ -163,21 +163,20 @@ class TextStyle {
}
int
get
hashCode
{
// Use Quiver: https://github.com/domokit/mojo/issues/236
int
value
=
373
;
value
=
37
*
value
+
inherit
.
hashCode
;
value
=
37
*
value
+
color
.
hashCode
;
value
=
37
*
value
+
fontFamily
.
hashCode
;
value
=
37
*
value
+
fontSize
.
hashCode
;
value
=
37
*
value
+
fontWeight
.
hashCode
;
value
=
37
*
value
+
fontStyle
.
hashCode
;
value
=
37
*
value
+
letterSpacing
.
hashCode
;
value
=
37
*
value
+
textAlign
.
hashCode
;
value
=
37
*
value
+
textBaseline
.
hashCode
;
value
=
37
*
value
+
decoration
.
hashCode
;
value
=
37
*
value
+
decorationColor
.
hashCode
;
value
=
37
*
value
+
decorationStyle
.
hashCode
;
return
value
;
return
hashValues
(
super
.
hashCode
,
color
,
fontFamily
,
fontSize
,
fontWeight
,
fontStyle
,
letterSpacing
,
textAlign
,
textBaseline
,
decoration
,
decorationColor
,
decorationStyle
);
}
String
toString
([
String
prefix
=
''
])
{
...
...
packages/flutter/lib/src/rendering/box.dart
View file @
e78d6cbc
...
...
@@ -4,6 +4,7 @@
import
'dart:math'
as
math
;
import
'dart:ui'
as
ui
;
import
'dart:ui'
show
hashValues
;
import
'package:flutter/animation.dart'
;
import
'package:flutter/gestures.dart'
;
...
...
@@ -272,12 +273,7 @@ class BoxConstraints extends Constraints {
int
get
hashCode
{
assert
(
isNormalized
);
int
value
=
373
;
value
=
37
*
value
+
minWidth
.
hashCode
;
value
=
37
*
value
+
maxWidth
.
hashCode
;
value
=
37
*
value
+
minHeight
.
hashCode
;
value
=
37
*
value
+
maxHeight
.
hashCode
;
return
value
;
return
hashValues
(
minWidth
,
maxWidth
,
minHeight
,
maxHeight
);
}
String
toString
()
{
...
...
packages/flutter/lib/src/rendering/stack.dart
View file @
e78d6cbc
...
...
@@ -3,7 +3,7 @@
// found in the LICENSE file.
import
'dart:math'
as
math
;
import
'dart:ui'
show
lerpDouble
;
import
'dart:ui'
show
lerpDouble
,
hashValues
;
import
'box.dart'
;
import
'object.dart'
;
...
...
@@ -123,14 +123,7 @@ class RelativeRect {
bottom
==
typedOther
.
bottom
;
}
int
get
hashCode
{
int
value
=
373
;
value
=
37
*
value
+
left
.
hashCode
;
value
=
37
*
value
+
top
.
hashCode
;
value
=
37
*
value
+
right
.
hashCode
;
value
=
37
*
value
+
bottom
.
hashCode
;
return
value
;
}
int
get
hashCode
=>
hashValues
(
left
,
top
,
right
,
bottom
);
String
toString
()
=>
"RelativeRect.fromLTRB(
${left.toStringAsFixed(1)}
,
${top.toStringAsFixed(1)}
,
${right.toStringAsFixed(1)}
,
${bottom.toStringAsFixed(1)}
)"
;
}
...
...
packages/flutter/lib/src/widgets/framework.dart
View file @
e78d6cbc
...
...
@@ -7,6 +7,7 @@ import 'dart:collection';
import
'package:flutter/rendering.dart'
;
export
'dart:ui'
show
hashValues
,
hashList
;
export
'package:flutter/rendering.dart'
show
debugPrint
;
// KEYS
...
...
packages/flutter/lib/src/widgets/mixed_viewport.dart
View file @
e78d6cbc
...
...
@@ -63,7 +63,7 @@ class _ChildKey {
return
type
==
typedOther
.
type
&&
key
==
typedOther
.
key
;
}
int
get
hashCode
=>
((
373
*
37
)
+
type
.
hashCode
)
*
37
+
key
.
hashCode
;
int
get
hashCode
=>
hashValues
(
type
,
key
)
;
String
toString
()
=>
"_ChildKey(type:
$type
, key:
$key
)"
;
}
...
...
packages/flutter/lib/src/widgets/page_storage.dart
View file @
e78d6cbc
...
...
@@ -30,16 +30,7 @@ class _StorageEntryIdentifier {
}
return
true
;
}
int
get
hashCode
{
int
value
=
373
;
value
=
37
*
value
+
clientType
.
hashCode
;
value
=
37
*
value
+
scopeKey
.
hashCode
;
if
(
keys
!=
null
)
{
for
(
Key
key
in
keys
)
value
=
37
*
value
+
key
.
hashCode
;
}
return
value
;
}
int
get
hashCode
=>
hashValues
(
clientType
,
scopeKey
,
hashList
(
keys
));
}
class
PageStorageBucket
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment