Migrate vitool to null safety (#84011)

This commit is contained in:
Michael Goderbauer 2021-06-04 13:58:21 -07:00 committed by GitHub
parent c3e04da074
commit 2f88966935
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 20 deletions

View file

@ -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) {

View file

@ -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