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
2f889669
Unverified
Commit
2f889669
authored
Jun 04, 2021
by
Michael Goderbauer
Committed by
GitHub
Jun 04, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate vitool to null safety (#84011)
parent
c3e04da0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
20 deletions
+18
-20
vitool.dart
dev/tools/vitool/lib/vitool.dart
+17
-19
pubspec.yaml
dev/tools/vitool/pubspec.yaml
+1
-1
No files found.
dev/tools/vitool/lib/vitool.dart
View file @
2f889669
...
...
@@ -68,7 +68,7 @@ class Animation {
/// Represents the animation of a single path.
class
PathAnimation
{
const
PathAnimation
(
this
.
commands
,
{
@
required
this
.
opacities
});
const
PathAnimation
(
this
.
commands
,
{
required
this
.
opacities
});
factory
PathAnimation
.
fromFrameData
(
List
<
FrameData
>
frames
,
int
pathIdx
)
{
if
(
frames
.
isEmpty
)
...
...
@@ -77,9 +77,7 @@ class PathAnimation {
final
List
<
PathCommandAnimation
>
commands
=
<
PathCommandAnimation
>[];
for
(
int
commandIdx
=
0
;
commandIdx
<
frames
[
0
].
paths
[
pathIdx
].
commands
.
length
;
commandIdx
+=
1
)
{
final
int
numPointsInCommand
=
frames
[
0
].
paths
[
pathIdx
].
commands
[
commandIdx
].
points
.
length
;
final
List
<
List
<
Point
<
double
>>>
points
=
List
<
List
<
Point
<
double
>>>.
filled
(
numPointsInCommand
,
null
);
for
(
int
j
=
0
;
j
<
numPointsInCommand
;
j
+=
1
)
points
[
j
]
=
<
Point
<
double
>>[];
final
List
<
List
<
Point
<
double
>>>
points
=
List
<
List
<
Point
<
double
>>>.
filled
(
numPointsInCommand
,
<
Point
<
double
>>[]);
final
String
commandType
=
frames
[
0
].
paths
[
pathIdx
].
commands
[
commandIdx
].
type
;
for
(
int
i
=
0
;
i
<
frames
.
length
;
i
+=
1
)
{
final
FrameData
frame
=
frames
[
i
];
...
...
@@ -248,12 +246,12 @@ List<Point<double>> parsePoints(String points) {
String
unParsed
=
points
;
final
List
<
Point
<
double
>>
result
=
<
Point
<
double
>>[];
while
(
unParsed
.
isNotEmpty
&&
_pointMatcher
.
hasMatch
(
unParsed
))
{
final
Match
m
=
_pointMatcher
.
firstMatch
(
unParsed
);
final
Match
m
=
_pointMatcher
.
firstMatch
(
unParsed
)
!
;
result
.
add
(
Point
<
double
>(
double
.
parse
(
m
.
group
(
1
)),
double
.
parse
(
m
.
group
(
2
)),
double
.
parse
(
m
.
group
(
1
)
!
),
double
.
parse
(
m
.
group
(
2
)
!
),
));
unParsed
=
m
.
group
(
3
);
unParsed
=
m
.
group
(
3
)
!
;
}
return
result
;
}
...
...
@@ -306,8 +304,8 @@ class SvgPath {
if
(!
_pathCommandValidator
.
hasMatch
(
dAttr
))
throw
Exception
(
'illegal or unsupported path d expression:
$dAttr
'
);
for
(
final
Match
match
in
_pathCommandMatcher
.
allMatches
(
dAttr
))
{
final
String
commandType
=
match
.
group
(
1
);
final
String
pointStr
=
match
.
group
(
2
);
final
String
commandType
=
match
.
group
(
1
)
!
;
final
String
pointStr
=
match
.
group
(
2
)
!
;
commands
.
add
(
commandsBuilder
.
build
(
commandType
,
parsePoints
(
pointStr
)));
}
return
SvgPath
(
id
,
commands
);
...
...
@@ -422,7 +420,7 @@ class SvgPathCommandBuilder {
}
List
<
double
>
_pointsToVector3Array
(
List
<
Point
<
double
>>
points
)
{
final
List
<
double
>
result
=
List
<
double
>.
filled
(
points
.
length
*
3
,
null
);
final
List
<
double
>
result
=
List
<
double
>.
filled
(
points
.
length
*
3
,
0.0
);
for
(
int
i
=
0
;
i
<
points
.
length
;
i
+=
1
)
{
result
[
i
*
3
]
=
points
[
i
].
x
;
result
[
i
*
3
+
1
]
=
points
[
i
].
y
;
...
...
@@ -433,10 +431,10 @@ List<double> _pointsToVector3Array(List<Point<double>> points) {
List
<
Point
<
double
>>
_vector3ArrayToPoints
(
List
<
double
>
vector
)
{
final
int
numPoints
=
(
vector
.
length
/
3
).
floor
();
final
List
<
Point
<
double
>>
points
=
List
<
Point
<
double
>>.
filled
(
numPoints
,
null
);
for
(
int
i
=
0
;
i
<
numPoints
;
i
+=
1
)
{
points
[
i
]
=
Point
<
double
>(
vector
[
i
*
3
],
vector
[
i
*
3
+
1
]);
}
final
List
<
Point
<
double
>>
points
=
<
Point
<
double
>>[
for
(
int
i
=
0
;
i
<
numPoints
;
i
+=
1
)
Point
<
double
>(
vector
[
i
*
3
],
vector
[
i
*
3
+
1
]),
];
return
points
;
}
...
...
@@ -447,7 +445,7 @@ List<Point<double>> _vector3ArrayToPoints(List<double> vector) {
class
_Transform
{
/// Constructs a new _Transform, default arguments create a no-op transform.
_Transform
({
Matrix3
transformMatrix
,
this
.
opacity
=
1.0
})
:
_Transform
({
Matrix3
?
transformMatrix
,
this
.
opacity
=
1.0
})
:
transformMatrix
=
transformMatrix
??
Matrix3
.
identity
();
final
Matrix3
transformMatrix
;
...
...
@@ -472,8 +470,8 @@ Matrix3 _parseSvgTransform(String transform) {
final
Iterable
<
Match
>
matches
=
_transformCommand
.
allMatches
(
transform
).
toList
().
reversed
;
Matrix3
result
=
Matrix3
.
identity
();
for
(
final
Match
m
in
matches
)
{
final
String
command
=
m
.
group
(
1
);
final
String
params
=
m
.
group
(
2
);
final
String
command
=
m
.
group
(
1
)
!
;
final
String
params
=
m
.
group
(
2
)
!
;
if
(
command
==
'translate'
)
{
result
=
_parseSvgTranslate
(
params
).
multiplied
(
result
);
continue
;
...
...
@@ -533,7 +531,7 @@ int parsePixels(String pixels) {
throw
ArgumentError
(
"illegal pixels expression: '
$pixels
'"
' (the tool currently only support pixel units).'
);
return
int
.
parse
(
_pixelsExp
.
firstMatch
(
pixels
)
.
group
(
1
)
);
return
int
.
parse
(
_pixelsExp
.
firstMatch
(
pixels
)
!.
group
(
1
)!
);
}
String
_extractAttr
(
XmlElement
element
,
String
name
)
{
...
...
dev/tools/vitool/pubspec.yaml
View file @
2f889669
...
...
@@ -5,7 +5,7 @@ homepage: https://flutter.dev
author
:
Flutter Authors <flutter-dev@googlegroups.com>
environment
:
sdk
:
"
>=2.
2.2
<3.0.0"
sdk
:
"
>=2.
12.0
<3.0.0"
dependencies
:
args
:
2.1.1
...
...
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