Migrate vitool to null safety (#84011)
This commit is contained in:
parent
c3e04da074
commit
2f88966935
@ -68,7 +68,7 @@ class Animation {
|
|||||||
|
|
||||||
/// Represents the animation of a single path.
|
/// Represents the animation of a single path.
|
||||||
class PathAnimation {
|
class PathAnimation {
|
||||||
const PathAnimation(this.commands, {@required this.opacities});
|
const PathAnimation(this.commands, {required this.opacities});
|
||||||
|
|
||||||
factory PathAnimation.fromFrameData(List<FrameData> frames, int pathIdx) {
|
factory PathAnimation.fromFrameData(List<FrameData> frames, int pathIdx) {
|
||||||
if (frames.isEmpty)
|
if (frames.isEmpty)
|
||||||
@ -77,9 +77,7 @@ class PathAnimation {
|
|||||||
final List<PathCommandAnimation> commands = <PathCommandAnimation>[];
|
final List<PathCommandAnimation> commands = <PathCommandAnimation>[];
|
||||||
for (int commandIdx = 0; commandIdx < frames[0].paths[pathIdx].commands.length; commandIdx += 1) {
|
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 int numPointsInCommand = frames[0].paths[pathIdx].commands[commandIdx].points.length;
|
||||||
final List<List<Point<double>>> points = List<List<Point<double>>>.filled(numPointsInCommand, null);
|
final List<List<Point<double>>> points = List<List<Point<double>>>.filled(numPointsInCommand, <Point<double>>[]);
|
||||||
for (int j = 0; j < numPointsInCommand; j += 1)
|
|
||||||
points[j] = <Point<double>>[];
|
|
||||||
final String commandType = frames[0].paths[pathIdx].commands[commandIdx].type;
|
final String commandType = frames[0].paths[pathIdx].commands[commandIdx].type;
|
||||||
for (int i = 0; i < frames.length; i += 1) {
|
for (int i = 0; i < frames.length; i += 1) {
|
||||||
final FrameData frame = frames[i];
|
final FrameData frame = frames[i];
|
||||||
@ -248,12 +246,12 @@ List<Point<double>> parsePoints(String points) {
|
|||||||
String unParsed = points;
|
String unParsed = points;
|
||||||
final List<Point<double>> result = <Point<double>>[];
|
final List<Point<double>> result = <Point<double>>[];
|
||||||
while (unParsed.isNotEmpty && _pointMatcher.hasMatch(unParsed)) {
|
while (unParsed.isNotEmpty && _pointMatcher.hasMatch(unParsed)) {
|
||||||
final Match m = _pointMatcher.firstMatch(unParsed);
|
final Match m = _pointMatcher.firstMatch(unParsed)!;
|
||||||
result.add(Point<double>(
|
result.add(Point<double>(
|
||||||
double.parse(m.group(1)),
|
double.parse(m.group(1)!),
|
||||||
double.parse(m.group(2)),
|
double.parse(m.group(2)!),
|
||||||
));
|
));
|
||||||
unParsed = m.group(3);
|
unParsed = m.group(3)!;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -306,8 +304,8 @@ class SvgPath {
|
|||||||
if (!_pathCommandValidator.hasMatch(dAttr))
|
if (!_pathCommandValidator.hasMatch(dAttr))
|
||||||
throw Exception('illegal or unsupported path d expression: $dAttr');
|
throw Exception('illegal or unsupported path d expression: $dAttr');
|
||||||
for (final Match match in _pathCommandMatcher.allMatches(dAttr)) {
|
for (final Match match in _pathCommandMatcher.allMatches(dAttr)) {
|
||||||
final String commandType = match.group(1);
|
final String commandType = match.group(1)!;
|
||||||
final String pointStr = match.group(2);
|
final String pointStr = match.group(2)!;
|
||||||
commands.add(commandsBuilder.build(commandType, parsePoints(pointStr)));
|
commands.add(commandsBuilder.build(commandType, parsePoints(pointStr)));
|
||||||
}
|
}
|
||||||
return SvgPath(id, commands);
|
return SvgPath(id, commands);
|
||||||
@ -422,7 +420,7 @@ class SvgPathCommandBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<double> _pointsToVector3Array(List<Point<double>> points) {
|
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) {
|
for (int i = 0; i < points.length; i += 1) {
|
||||||
result[i * 3] = points[i].x;
|
result[i * 3] = points[i].x;
|
||||||
result[i * 3 + 1] = points[i].y;
|
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) {
|
List<Point<double>> _vector3ArrayToPoints(List<double> vector) {
|
||||||
final int numPoints = (vector.length / 3).floor();
|
final int numPoints = (vector.length / 3).floor();
|
||||||
final List<Point<double>> points = List<Point<double>>.filled(numPoints, null);
|
final List<Point<double>> points = <Point<double>>[
|
||||||
for (int i = 0; i < numPoints; i += 1) {
|
for (int i = 0; i < numPoints; i += 1)
|
||||||
points[i] = Point<double>(vector[i*3], vector[i*3 + 1]);
|
Point<double>(vector[i*3], vector[i*3 + 1]),
|
||||||
}
|
];
|
||||||
return points;
|
return points;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -447,7 +445,7 @@ List<Point<double>> _vector3ArrayToPoints(List<double> vector) {
|
|||||||
class _Transform {
|
class _Transform {
|
||||||
|
|
||||||
/// Constructs a new _Transform, default arguments create a no-op 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();
|
transformMatrix = transformMatrix ?? Matrix3.identity();
|
||||||
|
|
||||||
final Matrix3 transformMatrix;
|
final Matrix3 transformMatrix;
|
||||||
@ -472,8 +470,8 @@ Matrix3 _parseSvgTransform(String transform) {
|
|||||||
final Iterable<Match> matches =_transformCommand.allMatches(transform).toList().reversed;
|
final Iterable<Match> matches =_transformCommand.allMatches(transform).toList().reversed;
|
||||||
Matrix3 result = Matrix3.identity();
|
Matrix3 result = Matrix3.identity();
|
||||||
for (final Match m in matches) {
|
for (final Match m in matches) {
|
||||||
final String command = m.group(1);
|
final String command = m.group(1)!;
|
||||||
final String params = m.group(2);
|
final String params = m.group(2)!;
|
||||||
if (command == 'translate') {
|
if (command == 'translate') {
|
||||||
result = _parseSvgTranslate(params).multiplied(result);
|
result = _parseSvgTranslate(params).multiplied(result);
|
||||||
continue;
|
continue;
|
||||||
@ -533,7 +531,7 @@ int parsePixels(String pixels) {
|
|||||||
throw ArgumentError(
|
throw ArgumentError(
|
||||||
"illegal pixels expression: '$pixels'"
|
"illegal pixels expression: '$pixels'"
|
||||||
' (the tool currently only support pixel units).');
|
' (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) {
|
String _extractAttr(XmlElement element, String name) {
|
||||||
|
@ -5,7 +5,7 @@ homepage: https://flutter.dev
|
|||||||
author: Flutter Authors <flutter-dev@googlegroups.com>
|
author: Flutter Authors <flutter-dev@googlegroups.com>
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.2.2 <3.0.0"
|
sdk: ">=2.12.0 <3.0.0"
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
args: 2.1.1
|
args: 2.1.1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user