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
ebb48e16
Unverified
Commit
ebb48e16
authored
Oct 27, 2021
by
Everskies
Committed by
GitHub
Oct 27, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add missing transform == check for gradients (#91898)
parent
bb6e3aff
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
92 additions
and
7 deletions
+92
-7
gradient.dart
packages/flutter/lib/src/painting/gradient.dart
+57
-6
gradient_test.dart
packages/flutter/test/painting/gradient_test.dart
+35
-1
No files found.
packages/flutter/lib/src/painting/gradient.dart
View file @
ebb48e16
...
...
@@ -118,6 +118,24 @@ class GradientRotation extends GradientTransform {
..
translate
(
originX
,
originY
)
..
rotateZ
(
radians
);
}
@override
bool
operator
==(
Object
other
)
{
if
(
identical
(
this
,
other
))
return
true
;
if
(
other
.
runtimeType
!=
runtimeType
)
return
false
;
return
other
is
GradientRotation
&&
other
.
radians
==
radians
;
}
@override
int
get
hashCode
=>
radians
.
hashCode
;
@override
String
toString
()
{
return
'
${objectRuntimeType(this, 'GradientRotation')}
(radians:
${debugFormatDouble(radians)}
)'
;
}
}
/// A 2D gradient.
...
...
@@ -495,16 +513,26 @@ class LinearGradient extends Gradient {
&&
other
.
begin
==
begin
&&
other
.
end
==
end
&&
other
.
tileMode
==
tileMode
&&
other
.
transform
==
transform
&&
listEquals
<
Color
>(
other
.
colors
,
colors
)
&&
listEquals
<
double
>(
other
.
stops
,
stops
);
}
@override
int
get
hashCode
=>
hashValues
(
begin
,
end
,
tileMode
,
hashList
(
colors
),
hashList
(
stops
));
int
get
hashCode
=>
hashValues
(
begin
,
end
,
tileMode
,
transform
,
hashList
(
colors
),
hashList
(
stops
));
@override
String
toString
()
{
return
'
${objectRuntimeType(this, 'LinearGradient')}
(
$begin
,
$end
,
$colors
,
$stops
,
$tileMode
)'
;
final
List
<
String
>
description
=
<
String
>[
'begin:
$begin
'
,
'end:
$end
'
,
'colors:
$colors
'
,
if
(
stops
!=
null
)
'stops:
$stops
'
,
'tileMode:
$tileMode
'
,
if
(
transform
!=
null
)
'transform:
$transform
'
,
];
return
'
${objectRuntimeType(this, 'LinearGradient')}
(
${description.join(', ')}
)'
;
}
}
...
...
@@ -757,6 +785,7 @@ class RadialGradient extends Gradient {
&&
other
.
center
==
center
&&
other
.
radius
==
radius
&&
other
.
tileMode
==
tileMode
&&
other
.
transform
==
transform
&&
listEquals
<
Color
>(
other
.
colors
,
colors
)
&&
listEquals
<
double
>(
other
.
stops
,
stops
)
&&
other
.
focal
==
focal
...
...
@@ -764,11 +793,22 @@ class RadialGradient extends Gradient {
}
@override
int
get
hashCode
=>
hashValues
(
center
,
radius
,
tileMode
,
hashList
(
colors
),
hashList
(
stops
),
focal
,
focalRadius
);
int
get
hashCode
=>
hashValues
(
center
,
radius
,
tileMode
,
transform
,
hashList
(
colors
),
hashList
(
stops
),
focal
,
focalRadius
);
@override
String
toString
()
{
return
'
${objectRuntimeType(this, 'RadialGradient')}
(
$center
,
$radius
,
$colors
,
$stops
,
$tileMode
,
$focal
,
$focalRadius
)'
;
final
List
<
String
>
description
=
<
String
>[
'center:
$center
'
,
'radius:
${debugFormatDouble(radius)}
'
,
'colors:
$colors
'
,
if
(
stops
!=
null
)
'stops:
$stops
'
,
'tileMode:
$tileMode
'
,
if
(
focal
!=
null
)
'focal:
$focal
'
,
'focalRadius:
${debugFormatDouble(focalRadius)}
'
,
if
(
transform
!=
null
)
'transform:
$transform
'
,
];
return
'
${objectRuntimeType(this, 'RadialGradient')}
(
${description.join(', ')}
)'
;
}
}
...
...
@@ -1005,15 +1045,26 @@ class SweepGradient extends Gradient {
&&
other
.
startAngle
==
startAngle
&&
other
.
endAngle
==
endAngle
&&
other
.
tileMode
==
tileMode
&&
other
.
transform
==
transform
&&
listEquals
<
Color
>(
other
.
colors
,
colors
)
&&
listEquals
<
double
>(
other
.
stops
,
stops
);
}
@override
int
get
hashCode
=>
hashValues
(
center
,
startAngle
,
endAngle
,
tileMode
,
hashList
(
colors
),
hashList
(
stops
));
int
get
hashCode
=>
hashValues
(
center
,
startAngle
,
endAngle
,
tileMode
,
transform
,
hashList
(
colors
),
hashList
(
stops
));
@override
String
toString
()
{
return
'
${objectRuntimeType(this, 'SweepGradient')}
(
$center
,
$startAngle
,
$endAngle
,
$colors
,
$stops
,
$tileMode
)'
;
final
List
<
String
>
description
=
<
String
>[
'center:
$center
'
,
'startAngle:
${debugFormatDouble(startAngle)}
'
,
'endAngle:
${debugFormatDouble(endAngle)}
'
,
'colors:
$colors
'
,
if
(
stops
!=
null
)
'stops:
$stops
'
,
'tileMode:
$tileMode
'
,
if
(
transform
!=
null
)
'transform:
$transform
'
,
];
return
'
${objectRuntimeType(this, 'SweepGradient')}
(
${description.join(', ')}
)'
;
}
}
packages/flutter/test/painting/gradient_test.dart
View file @
ebb48e16
...
...
@@ -184,17 +184,51 @@ void main() {
const
LinearGradient
(
begin:
Alignment
.
topLeft
,
end:
Alignment
.
bottomLeft
,
transform:
GradientRotation
(
1.6
),
colors:
<
Color
>[
Color
(
0x33333333
),
Color
(
0x66666666
),
],
).
toString
(),
equals
(
'LinearGradient(
Alignment.topLeft, Alignment.bottomLeft, [Color(0x33333333), Color(0x66666666)], null, TileMode.clamp
)'
,
'LinearGradient(
begin: Alignment.topLeft, end: Alignment.bottomLeft, colors: [Color(0x33333333), Color(0x66666666)], tileMode: TileMode.clamp, transform: GradientRotation(radians: 1.6)
)'
,
),
);
});
test
(
'LinearGradient with different transforms'
,
()
{
const
LinearGradient
testGradient1
=
LinearGradient
(
transform:
GradientRotation
(
math
.
pi
/
4
),
colors:
<
Color
>[
Color
(
0x33333333
),
Color
(
0x66666666
),
],
);
const
LinearGradient
testGradient1Copy
=
LinearGradient
(
transform:
GradientRotation
(
math
.
pi
/
4
),
colors:
<
Color
>[
Color
(
0x33333333
),
Color
(
0x66666666
),
],
);
const
LinearGradient
testGradient2
=
LinearGradient
(
transform:
GradientRotation
(
math
.
pi
/
2
),
colors:
<
Color
>[
Color
(
0x33333333
),
Color
(
0x66666666
),
],
);
expect
(
testGradient1
,
equals
(
testGradient1Copy
),
);
expect
(
testGradient1
,
isNot
(
equals
(
testGradient2
)),
);
});
test
(
'LinearGradient with AlignmentDirectional'
,
()
{
expect
(
()
{
...
...
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