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
d89deb79
Commit
d89deb79
authored
Mar 21, 2018
by
Keenan
Committed by
xster
Mar 21, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix call on null when interpolating gradient stops (#15656)
Also adds test for interpolating gradient stops.
parent
4d32c085
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
83 additions
and
0 deletions
+83
-0
gradient.dart
packages/flutter/lib/src/painting/gradient.dart
+1
-0
gradient_test.dart
packages/flutter/test/painting/gradient_test.dart
+82
-0
No files found.
packages/flutter/lib/src/painting/gradient.dart
View file @
d89deb79
...
...
@@ -28,6 +28,7 @@ _ColorsAndStops _interpolateColorsAndStops(List<Color> aColors, List<double> aSt
aStops
??=
const
<
double
>[
0.0
,
1.0
];
bStops
??=
const
<
double
>[
0.0
,
1.0
];
assert
(
aStops
.
length
==
bStops
.
length
);
interpolatedStops
=
<
double
>[];
for
(
int
i
=
0
;
i
<
aStops
.
length
;
i
+=
1
)
interpolatedStops
.
add
(
ui
.
lerpDouble
(
aStops
[
i
],
bStops
[
i
],
t
).
clamp
(
0.0
,
1.0
));
}
...
...
packages/flutter/test/painting/gradient_test.dart
View file @
d89deb79
...
...
@@ -58,6 +58,47 @@ void main() {
));
});
test
(
'LinearGradient lerp test with stops'
,
()
{
const
LinearGradient
testGradient1
=
const
LinearGradient
(
begin:
Alignment
.
topLeft
,
end:
Alignment
.
bottomLeft
,
colors:
const
<
Color
>[
const
Color
(
0x33333333
),
const
Color
(
0x66666666
),
],
stops:
const
<
double
>[
0.0
,
0.5
,
],
);
const
LinearGradient
testGradient2
=
const
LinearGradient
(
begin:
Alignment
.
topRight
,
end:
Alignment
.
topLeft
,
colors:
const
<
Color
>[
const
Color
(
0x44444444
),
const
Color
(
0x88888888
),
],
stops:
const
<
double
>[
0.5
,
1.0
,
],
);
final
LinearGradient
actual
=
LinearGradient
.
lerp
(
testGradient1
,
testGradient2
,
0.5
);
expect
(
actual
,
const
LinearGradient
(
begin:
const
Alignment
(
0.0
,
-
1.0
),
end:
const
Alignment
(-
1.0
,
0.0
),
colors:
const
<
Color
>[
const
Color
(
0x3B3B3B3B
),
const
Color
(
0x77777777
),
],
stops:
const
<
double
>[
0.25
,
0.75
,
],
));
});
test
(
'LinearGradient toString'
,
()
{
expect
(
const
LinearGradient
(
...
...
@@ -181,6 +222,47 @@ void main() {
));
});
test
(
'RadialGradient lerp test with stops'
,
()
{
const
RadialGradient
testGradient1
=
const
RadialGradient
(
center:
Alignment
.
topLeft
,
radius:
20.0
,
colors:
const
<
Color
>[
const
Color
(
0x33333333
),
const
Color
(
0x66666666
),
],
stops:
const
<
double
>[
0.0
,
0.5
,
],
);
const
RadialGradient
testGradient2
=
const
RadialGradient
(
center:
Alignment
.
topRight
,
radius:
10.0
,
colors:
const
<
Color
>[
const
Color
(
0x44444444
),
const
Color
(
0x88888888
),
],
stops:
const
<
double
>[
0.5
,
1.0
,
],
);
final
RadialGradient
actual
=
RadialGradient
.
lerp
(
testGradient1
,
testGradient2
,
0.5
);
expect
(
actual
,
const
RadialGradient
(
center:
const
Alignment
(
0.0
,
-
1.0
),
radius:
15.0
,
colors:
const
<
Color
>[
const
Color
(
0x3B3B3B3B
),
const
Color
(
0x77777777
),
],
stops:
const
<
double
>[
0.25
,
0.75
,
],
));
});
test
(
'Gradient lerp test (with RadialGradient)'
,
()
{
const
RadialGradient
testGradient1
=
const
RadialGradient
(
center:
Alignment
.
topLeft
,
...
...
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