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
9f0da30f
Unverified
Commit
9f0da30f
authored
Aug 29, 2022
by
Greg Spencer
Committed by
GitHub
Aug 29, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix an exception in `StarBorder`s that are scaled to small or infinite sizes (#110419)
parent
c6870ee9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
5 deletions
+34
-5
star_border.dart
packages/flutter/lib/src/painting/star_border.dart
+6
-5
star_border_test.dart
packages/flutter/test/painting/star_border_test.dart
+28
-0
No files found.
packages/flutter/lib/src/painting/star_border.dart
View file @
9f0da30f
...
...
@@ -514,7 +514,6 @@ class _StarGenerator {
}
else
{
scale
=
Offset
(
squash
*
scale
.
dx
+
(
1
-
squash
)
*
scale
.
dy
,
scale
.
dy
);
}
// Scale the border so that it matches the size of the widget rectangle, so
// that "rotation" of the shape doesn't affect how much of the rectangle it
// covers.
...
...
@@ -610,10 +609,12 @@ class _StarGenerator {
}
// The rounding added to the valley radius can sometimes push it outside of
// the rounding of the point, since the rounding amount can be different, so
// we have to evaluate both the valley and the point radii, and pick the
// largest.
return
math
.
max
(
valleyRadius
,
pointRadius
);
// the rounding of the point, since the rounding amount can be different
// between the points and the valleys, so we have to evaluate both the
// valley and the point radii, and pick the largest. Also, since this value
// is used later to determine the scale, we need to keep it finite and
// non-zero.
return
clampDouble
(
math
.
max
(
valleyRadius
,
pointRadius
),
double
.
minPositive
,
double
.
maxFinite
);
}
void
_drawPoints
(
Path
path
,
List
<
_PointInfo
>
points
)
{
...
...
packages/flutter/test/painting/star_border_test.dart
View file @
9f0da30f
...
...
@@ -132,6 +132,34 @@ void main() {
const
StarBorder
.
polygon
(
side:
BorderSide
(
color:
Color
(
0xffff0000
),
strokeAlign:
BorderSide
.
strokeAlignOutside
)));
});
testWidgets
(
"StarBorder doesn't try to scale an infinite scale matrix"
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Center
(
child:
SizedBox
(
width:
100
,
height:
100
,
child:
Stack
(
children:
<
Widget
>
[
Positioned
.
fromRelativeRect
(
rect:
const
RelativeRect
.
fromLTRB
(
100
,
100
,
100
,
100
),
child:
Container
(
decoration:
const
ShapeDecoration
(
color:
Colors
.
green
,
shape:
StarBorder
(),
),
),
),
],
),
),
),
),
);
expect
(
tester
.
takeException
(),
isNull
);
});
testWidgets
(
'StarBorder lerped with StarBorder'
,
(
WidgetTester
tester
)
async
{
const
StarBorder
from
=
StarBorder
();
const
ShapeBorder
otherBorder
=
StarBorder
(
...
...
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