Compare commits
2 Commits
v0.6.0
...
error_buil
Author | SHA1 | Date | |
---|---|---|---|
27b2ec471f | |||
57faea6f5e |
@ -35,7 +35,7 @@ packages:
|
||||
name: characters
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.0-nullsafety"
|
||||
version: "1.0.0"
|
||||
charcode:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -56,7 +56,7 @@ packages:
|
||||
name: collection
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.15.0-nullsafety"
|
||||
version: "1.14.13"
|
||||
convert:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -157,7 +157,7 @@ packages:
|
||||
name: meta
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.3.0-nullsafety"
|
||||
version: "1.1.8"
|
||||
path:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -171,7 +171,7 @@ packages:
|
||||
name: path_provider
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.6.11"
|
||||
version: "1.6.14"
|
||||
path_provider_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -192,14 +192,14 @@ packages:
|
||||
name: path_provider_platform_interface
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.2"
|
||||
version: "1.0.3"
|
||||
pedantic:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: pedantic
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.9.2"
|
||||
version: "1.9.0"
|
||||
platform:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -274,14 +274,14 @@ packages:
|
||||
name: typed_data
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.3.0-nullsafety"
|
||||
version: "1.2.0"
|
||||
vector_math:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: vector_math
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.0-nullsafety"
|
||||
version: "2.0.8"
|
||||
xdg_directories:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -290,5 +290,5 @@ packages:
|
||||
source: hosted
|
||||
version: "0.1.0"
|
||||
sdks:
|
||||
dart: ">=2.9.0-18.0 <2.9.0"
|
||||
dart: ">=2.9.0-14.0.dev <3.0.0"
|
||||
flutter: ">=1.12.13+hotfix.5 <2.0.0"
|
||||
|
@ -34,7 +34,7 @@ flutter:
|
||||
- assets/Logo/
|
||||
- assets/Images/
|
||||
- assets/Images/WeAccept/
|
||||
- assets/Weather/
|
||||
- assets/weather/
|
||||
- assets/example_with_images/
|
||||
- assets/example_with_images/images/
|
||||
|
||||
|
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 5.7 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
Before Width: | Height: | Size: 95 KiB After Width: | Height: | Size: 95 KiB |
Before Width: | Height: | Size: 64 KiB After Width: | Height: | Size: 64 KiB |
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 63 KiB After Width: | Height: | Size: 63 KiB |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 54 KiB |
Before Width: | Height: | Size: 91 KiB After Width: | Height: | Size: 91 KiB |
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 42 KiB |
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 58 KiB |
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 38 KiB |
Before Width: | Height: | Size: 120 KiB After Width: | Height: | Size: 120 KiB |
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 54 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 66 KiB |
Before Width: | Height: | Size: 129 KiB After Width: | Height: | Size: 129 KiB |
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 54 KiB |
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 151 KiB After Width: | Height: | Size: 151 KiB |
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 43 KiB |
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 53 KiB |
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 42 KiB |
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 43 KiB |
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 37 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 35 KiB |
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 139 KiB After Width: | Height: | Size: 139 KiB |
Before Width: | Height: | Size: 9.9 KiB After Width: | Height: | Size: 9.9 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 41 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 72 KiB |
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 42 KiB |
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 58 KiB |
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 45 KiB |
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 45 KiB |
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
@ -13,6 +13,7 @@ import '../../model/layer/base_layer.dart';
|
||||
import '../../utils.dart';
|
||||
import '../../utils/dash_path.dart';
|
||||
import '../../utils/misc.dart';
|
||||
import '../../utils/path_factory.dart';
|
||||
import '../../utils/utils.dart';
|
||||
import '../../value/lottie_value_callback.dart';
|
||||
import '../keyframe/base_keyframe_animation.dart';
|
||||
@ -25,8 +26,8 @@ import 'trim_path_content.dart';
|
||||
|
||||
abstract class BaseStrokeContent
|
||||
implements KeyPathElementContent, DrawingContent {
|
||||
final Path _path = Path();
|
||||
final Path _trimPathPath = Path();
|
||||
final Path _path = PathFactory.create();
|
||||
final Path _trimPathPath = PathFactory.create();
|
||||
final LottieDrawable lottieDrawable;
|
||||
final BaseLayer layer;
|
||||
final List<_PathGroup> _pathGroups = <_PathGroup>[];
|
||||
|
@ -9,6 +9,7 @@ import '../../model/key_path.dart';
|
||||
import '../../model/key_path_element.dart';
|
||||
import '../../model/layer/base_layer.dart';
|
||||
import '../../utils.dart';
|
||||
import '../../utils/path_factory.dart';
|
||||
import '../../value/lottie_value_callback.dart';
|
||||
import '../keyframe/transform_keyframe_animation.dart';
|
||||
import 'content.dart';
|
||||
@ -43,7 +44,7 @@ class ContentGroup implements DrawingContent, PathContent, KeyPathElement {
|
||||
}
|
||||
|
||||
final Matrix4 _matrix = Matrix4.identity();
|
||||
final Path _path = Path();
|
||||
final Path _path = PathFactory.create();
|
||||
|
||||
@override
|
||||
final String name;
|
||||
|
@ -7,6 +7,7 @@ import '../../model/key_path.dart';
|
||||
import '../../model/layer/base_layer.dart';
|
||||
import '../../utils.dart';
|
||||
import '../../utils/misc.dart';
|
||||
import '../../utils/path_factory.dart';
|
||||
import '../../value/lottie_value_callback.dart';
|
||||
import '../keyframe/base_keyframe_animation.dart';
|
||||
import 'compound_trim_path_content.dart';
|
||||
@ -18,7 +19,7 @@ import 'trim_path_content.dart';
|
||||
class EllipseContent implements PathContent, KeyPathElementContent {
|
||||
static final double _ellipseControlPointPercentage = 0.55228;
|
||||
|
||||
final Path _path = Path();
|
||||
final Path _path = PathFactory.create();
|
||||
|
||||
@override
|
||||
final String name;
|
||||
|
@ -8,6 +8,7 @@ import '../../model/key_path.dart';
|
||||
import '../../model/layer/base_layer.dart';
|
||||
import '../../utils.dart';
|
||||
import '../../utils/misc.dart';
|
||||
import '../../utils/path_factory.dart';
|
||||
import '../../value/lottie_value_callback.dart';
|
||||
import '../keyframe/base_keyframe_animation.dart';
|
||||
import '../keyframe/value_callback_keyframe_animation.dart';
|
||||
@ -17,7 +18,7 @@ import 'key_path_element_content.dart';
|
||||
import 'path_content.dart';
|
||||
|
||||
class FillContent implements DrawingContent, KeyPathElementContent {
|
||||
final Path _path = Path();
|
||||
final Path _path = PathFactory.create();
|
||||
final Paint _paint = Paint();
|
||||
final BaseLayer layer;
|
||||
@override
|
||||
@ -70,6 +71,9 @@ class FillContent implements DrawingContent, KeyPathElementContent {
|
||||
var alpha =
|
||||
((parentAlpha / 255.0 * _opacityAnimation.value / 100.0) * 255).round();
|
||||
_paint.setAlpha(alpha.clamp(0, 255).toInt());
|
||||
if (lottieDrawable.antiAliasingSuggested) {
|
||||
_paint.isAntiAlias = true;
|
||||
}
|
||||
|
||||
if (_colorFilterAnimation != null) {
|
||||
_paint.colorFilter = _colorFilterAnimation.value;
|
||||
@ -77,11 +81,13 @@ class FillContent implements DrawingContent, KeyPathElementContent {
|
||||
|
||||
_path.reset();
|
||||
for (var i = 0; i < _paths.length; i++) {
|
||||
_path.addPath(_paths[i].getPath(), Offset.zero,
|
||||
matrix4: parentMatrix.storage);
|
||||
_path.addPath(_paths[i].getPath(), Offset.zero);
|
||||
}
|
||||
|
||||
canvas.save();
|
||||
canvas.transform(parentMatrix.storage);
|
||||
canvas.drawPath(_path, _paint);
|
||||
canvas.restore();
|
||||
|
||||
L.endSection('FillContent#draw');
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import '../../model/key_path.dart';
|
||||
import '../../model/layer/base_layer.dart';
|
||||
import '../../utils.dart';
|
||||
import '../../utils/misc.dart';
|
||||
import '../../utils/path_factory.dart';
|
||||
import '../../value/lottie_value_callback.dart';
|
||||
import '../keyframe/base_keyframe_animation.dart';
|
||||
import '../keyframe/value_callback_keyframe_animation.dart';
|
||||
@ -25,7 +26,7 @@ class GradientFillContent implements DrawingContent, KeyPathElementContent {
|
||||
final GradientFill _fill;
|
||||
final _linearGradientCache = <int, Gradient>{};
|
||||
final _radialGradientCache = <int, Gradient>{};
|
||||
final _path = Path();
|
||||
final _path = PathFactory.create();
|
||||
final _paint = Paint();
|
||||
final _paths = <PathContent>[];
|
||||
final BaseKeyframeAnimation<GradientColor, GradientColor> _colorAnimation;
|
||||
@ -85,15 +86,14 @@ class GradientFillContent implements DrawingContent, KeyPathElementContent {
|
||||
L.beginSection('GradientFillContent#draw');
|
||||
_path.reset();
|
||||
for (var i = 0; i < _paths.length; i++) {
|
||||
_path.addPath(_paths[i].getPath(), Offset.zero,
|
||||
matrix4: parentMatrix.storage);
|
||||
_path.addPath(_paths[i].getPath(), Offset.zero);
|
||||
}
|
||||
|
||||
Gradient gradient;
|
||||
if (_fill.gradientType == GradientType.linear) {
|
||||
gradient = _getLinearGradient(parentMatrix);
|
||||
gradient = _getLinearGradient();
|
||||
} else {
|
||||
gradient = _getRadialGradient(parentMatrix);
|
||||
gradient = _getRadialGradient();
|
||||
}
|
||||
|
||||
_paint.shader = gradient;
|
||||
@ -105,8 +105,14 @@ class GradientFillContent implements DrawingContent, KeyPathElementContent {
|
||||
var alpha =
|
||||
((parentAlpha / 255.0 * _opacityAnimation.value / 100.0) * 255).round();
|
||||
_paint.setAlpha(alpha.clamp(0, 255).toInt());
|
||||
if (lottieDrawable.antiAliasingSuggested) {
|
||||
_paint.isAntiAlias = true;
|
||||
}
|
||||
|
||||
canvas.save();
|
||||
canvas.transform(parentMatrix.storage);
|
||||
canvas.drawPath(_path, _paint);
|
||||
canvas.restore();
|
||||
L.endSection('GradientFillContent#draw');
|
||||
}
|
||||
|
||||
@ -124,8 +130,8 @@ class GradientFillContent implements DrawingContent, KeyPathElementContent {
|
||||
outBounds.right + 1, outBounds.bottom + 1);
|
||||
}
|
||||
|
||||
Gradient _getLinearGradient(Matrix4 parentMatrix) {
|
||||
var gradientHash = _getGradientHash(parentMatrix);
|
||||
Gradient _getLinearGradient() {
|
||||
var gradientHash = _getGradientHash();
|
||||
var gradient = _linearGradientCache[gradientHash];
|
||||
if (gradient != null) {
|
||||
return gradient;
|
||||
@ -135,14 +141,14 @@ class GradientFillContent implements DrawingContent, KeyPathElementContent {
|
||||
var gradientColor = _colorAnimation.value;
|
||||
var colors = _applyDynamicColorsIfNeeded(gradientColor.colors);
|
||||
var positions = gradientColor.positions;
|
||||
gradient = Gradient.linear(startPoint, endPoint, colors, positions,
|
||||
TileMode.clamp, parentMatrix.storage);
|
||||
gradient = Gradient.linear(
|
||||
startPoint, endPoint, colors, positions, TileMode.clamp);
|
||||
_linearGradientCache[gradientHash] = gradient;
|
||||
return gradient;
|
||||
}
|
||||
|
||||
Gradient _getRadialGradient(Matrix4 parentMatrix) {
|
||||
var gradientHash = _getGradientHash(parentMatrix);
|
||||
Gradient _getRadialGradient() {
|
||||
var gradientHash = _getGradientHash();
|
||||
var gradient = _radialGradientCache[gradientHash];
|
||||
if (gradient != null) {
|
||||
return gradient;
|
||||
@ -160,13 +166,13 @@ class GradientFillContent implements DrawingContent, KeyPathElementContent {
|
||||
if (radius <= 0) {
|
||||
radius = 0.001;
|
||||
}
|
||||
gradient = Gradient.radial(startPoint, radius, colors, positions,
|
||||
TileMode.clamp, parentMatrix.storage);
|
||||
gradient =
|
||||
Gradient.radial(startPoint, radius, colors, positions, TileMode.clamp);
|
||||
_radialGradientCache[gradientHash] = gradient;
|
||||
return gradient;
|
||||
}
|
||||
|
||||
int _getGradientHash(Matrix4 parentMatrix) {
|
||||
int _getGradientHash() {
|
||||
var startPointProgress =
|
||||
(_startPointAnimation.progress * _cacheSteps).round();
|
||||
var endPointProgress = (_endPointAnimation.progress * _cacheSteps).round();
|
||||
@ -181,7 +187,6 @@ class GradientFillContent implements DrawingContent, KeyPathElementContent {
|
||||
if (colorProgress != 0) {
|
||||
hash = hash * 31 * colorProgress;
|
||||
}
|
||||
hash *= 31 * parentMatrix.hashCode;
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
@ -1,15 +1,16 @@
|
||||
import 'dart:ui';
|
||||
import '../../model/content/merge_paths.dart';
|
||||
import '../../utils.dart';
|
||||
import '../../utils/path_factory.dart';
|
||||
import 'content.dart';
|
||||
import 'content_group.dart';
|
||||
import 'greedy_content.dart';
|
||||
import 'path_content.dart';
|
||||
|
||||
class MergePathsContent implements PathContent, GreedyContent {
|
||||
final Path _firstPath = Path();
|
||||
final Path _remainderPath = Path();
|
||||
final Path _path = Path();
|
||||
final Path _firstPath = PathFactory.create();
|
||||
final Path _remainderPath = PathFactory.create();
|
||||
final Path _path = PathFactory.create();
|
||||
|
||||
final List<PathContent> _pathContents = <PathContent>[];
|
||||
final MergePaths _mergePaths;
|
||||
|
@ -8,6 +8,7 @@ import '../../model/content/shape_trim_path.dart';
|
||||
import '../../model/key_path.dart';
|
||||
import '../../model/layer/base_layer.dart';
|
||||
import '../../utils/misc.dart';
|
||||
import '../../utils/path_factory.dart';
|
||||
import '../../value/lottie_value_callback.dart';
|
||||
import '../keyframe/base_keyframe_animation.dart';
|
||||
import 'compound_trim_path_content.dart';
|
||||
@ -23,7 +24,7 @@ class PolystarContent implements PathContent, KeyPathElementContent {
|
||||
/// work otherwise.
|
||||
static final _polystarMagicNumber = .47829;
|
||||
static final _polygonMagicNumber = .25;
|
||||
final _path = Path();
|
||||
final _path = PathFactory.create();
|
||||
|
||||
final LottieDrawable lottieDrawable;
|
||||
final PolystarShape _polystarShape;
|
||||
|
@ -8,6 +8,7 @@ import '../../model/content/shape_trim_path.dart';
|
||||
import '../../model/key_path.dart';
|
||||
import '../../model/layer/base_layer.dart';
|
||||
import '../../utils/misc.dart';
|
||||
import '../../utils/path_factory.dart';
|
||||
import '../../value/lottie_value_callback.dart';
|
||||
import '../keyframe/base_keyframe_animation.dart';
|
||||
import 'compound_trim_path_content.dart';
|
||||
@ -17,7 +18,7 @@ import 'path_content.dart';
|
||||
import 'trim_path_content.dart';
|
||||
|
||||
class RectangleContent implements KeyPathElementContent, PathContent {
|
||||
final _path = Path();
|
||||
final _path = PathFactory.create();
|
||||
|
||||
@override
|
||||
final String name;
|
||||
|
@ -7,6 +7,7 @@ import '../../model/key_path.dart';
|
||||
import '../../model/layer/base_layer.dart';
|
||||
import '../../utils.dart';
|
||||
import '../../utils/misc.dart';
|
||||
import '../../utils/path_factory.dart';
|
||||
import '../../value/lottie_value_callback.dart';
|
||||
import '../keyframe/base_keyframe_animation.dart';
|
||||
import '../keyframe/transform_keyframe_animation.dart';
|
||||
@ -24,7 +25,7 @@ class RepeaterContent
|
||||
GreedyContent,
|
||||
KeyPathElementContent {
|
||||
final Matrix4 _matrix = Matrix4.identity();
|
||||
final _path = Path();
|
||||
final _path = PathFactory.create();
|
||||
|
||||
final LottieDrawable lottieDrawable;
|
||||
final BaseLayer layer;
|
||||
|
@ -4,6 +4,7 @@ import '../../model/content/shape_path.dart';
|
||||
import '../../model/content/shape_trim_path.dart';
|
||||
import '../../model/layer/base_layer.dart';
|
||||
import '../../utils.dart';
|
||||
import '../../utils/path_factory.dart';
|
||||
import '../keyframe/base_keyframe_animation.dart';
|
||||
import 'compound_trim_path_content.dart';
|
||||
import 'content.dart';
|
||||
@ -11,7 +12,7 @@ import 'path_content.dart';
|
||||
import 'trim_path_content.dart';
|
||||
|
||||
class ShapeContent implements PathContent {
|
||||
final _path = Path();
|
||||
final _path = PathFactory.create();
|
||||
|
||||
final ShapePath _shape;
|
||||
|
||||
|
@ -1,12 +1,13 @@
|
||||
import 'dart:ui';
|
||||
import '../../model/content/shape_data.dart';
|
||||
import '../../utils/misc.dart';
|
||||
import '../../utils/path_factory.dart';
|
||||
import '../../value/keyframe.dart';
|
||||
import 'base_keyframe_animation.dart';
|
||||
|
||||
class ShapeKeyframeAnimation extends BaseKeyframeAnimation<ShapeData, Path> {
|
||||
final ShapeData _tempShapeData = ShapeData.empty();
|
||||
final Path _tempPath = Path();
|
||||
final Path _tempPath = PathFactory.create();
|
||||
|
||||
ShapeKeyframeAnimation(List<Keyframe<ShapeData>> keyframes)
|
||||
: super(keyframes);
|
||||
|
@ -50,6 +50,7 @@ class Lottie extends StatefulWidget {
|
||||
Key key,
|
||||
AssetBundle bundle,
|
||||
LottieFrameBuilder frameBuilder,
|
||||
LottieErrorWidgetBuilder errorBuilder,
|
||||
double width,
|
||||
double height,
|
||||
BoxFit fit,
|
||||
@ -71,6 +72,7 @@ class Lottie extends StatefulWidget {
|
||||
key: key,
|
||||
bundle: bundle,
|
||||
frameBuilder: frameBuilder,
|
||||
errorBuilder: errorBuilder,
|
||||
width: width,
|
||||
height: height,
|
||||
fit: fit,
|
||||
@ -93,6 +95,7 @@ class Lottie extends StatefulWidget {
|
||||
void Function(LottieComposition) onLoaded,
|
||||
Key key,
|
||||
LottieFrameBuilder frameBuilder,
|
||||
LottieErrorWidgetBuilder errorBuilder,
|
||||
double width,
|
||||
double height,
|
||||
BoxFit fit,
|
||||
@ -112,6 +115,7 @@ class Lottie extends StatefulWidget {
|
||||
onLoaded: onLoaded,
|
||||
key: key,
|
||||
frameBuilder: frameBuilder,
|
||||
errorBuilder: errorBuilder,
|
||||
width: width,
|
||||
height: height,
|
||||
fit: fit,
|
||||
@ -133,6 +137,7 @@ class Lottie extends StatefulWidget {
|
||||
void Function(LottieComposition) onLoaded,
|
||||
Key key,
|
||||
LottieFrameBuilder frameBuilder,
|
||||
LottieErrorWidgetBuilder errorBuilder,
|
||||
double width,
|
||||
double height,
|
||||
BoxFit fit,
|
||||
@ -152,6 +157,7 @@ class Lottie extends StatefulWidget {
|
||||
onLoaded: onLoaded,
|
||||
key: key,
|
||||
frameBuilder: frameBuilder,
|
||||
errorBuilder: errorBuilder,
|
||||
width: width,
|
||||
height: height,
|
||||
fit: fit,
|
||||
@ -173,6 +179,7 @@ class Lottie extends StatefulWidget {
|
||||
void Function(LottieComposition) onLoaded,
|
||||
Key key,
|
||||
LottieFrameBuilder frameBuilder,
|
||||
LottieErrorWidgetBuilder errorBuilder,
|
||||
double width,
|
||||
double height,
|
||||
BoxFit fit,
|
||||
@ -192,6 +199,7 @@ class Lottie extends StatefulWidget {
|
||||
onLoaded: onLoaded,
|
||||
key: key,
|
||||
frameBuilder: frameBuilder,
|
||||
errorBuilder: errorBuilder,
|
||||
width: width,
|
||||
height: height,
|
||||
fit: fit,
|
||||
|
@ -44,6 +44,7 @@ class LottieBuilder extends StatefulWidget {
|
||||
this.options,
|
||||
this.onLoaded,
|
||||
this.frameBuilder,
|
||||
this.errorBuilder,
|
||||
this.width,
|
||||
this.height,
|
||||
this.fit,
|
||||
@ -67,6 +68,7 @@ class LottieBuilder extends StatefulWidget {
|
||||
this.onLoaded,
|
||||
Key key,
|
||||
this.frameBuilder,
|
||||
this.errorBuilder,
|
||||
this.width,
|
||||
this.height,
|
||||
this.fit,
|
||||
@ -99,6 +101,7 @@ class LottieBuilder extends StatefulWidget {
|
||||
this.onLoaded,
|
||||
Key key,
|
||||
this.frameBuilder,
|
||||
this.errorBuilder,
|
||||
this.width,
|
||||
this.height,
|
||||
this.fit,
|
||||
@ -122,6 +125,7 @@ class LottieBuilder extends StatefulWidget {
|
||||
Key key,
|
||||
AssetBundle bundle,
|
||||
this.frameBuilder,
|
||||
this.errorBuilder,
|
||||
this.width,
|
||||
this.height,
|
||||
this.fit,
|
||||
@ -148,6 +152,7 @@ class LottieBuilder extends StatefulWidget {
|
||||
this.onLoaded,
|
||||
Key key,
|
||||
this.frameBuilder,
|
||||
this.errorBuilder,
|
||||
this.width,
|
||||
this.height,
|
||||
this.fit,
|
||||
@ -279,6 +284,12 @@ class LottieBuilder extends StatefulWidget {
|
||||
///
|
||||
final LottieFrameBuilder frameBuilder;
|
||||
|
||||
/// A builder function that is called if an error occurs during animation loading.
|
||||
///
|
||||
/// If this builder is not provided, it will use the `ErrorWidget` in debug mode
|
||||
/// and an empty box in release mode.
|
||||
final LottieErrorWidgetBuilder errorBuilder;
|
||||
|
||||
/// If non-null, require the lottie animation to have this width.
|
||||
///
|
||||
/// If null, the lottie animation will pick a size that best preserves its intrinsic
|
||||
@ -351,6 +362,7 @@ class LottieBuilder extends StatefulWidget {
|
||||
super.debugFillProperties(properties);
|
||||
properties.add(DiagnosticsProperty<LottieProvider>('lottie', lottie));
|
||||
properties.add(DiagnosticsProperty<Function>('frameBuilder', frameBuilder));
|
||||
properties.add(DiagnosticsProperty<Function>('errorBuilder', errorBuilder));
|
||||
properties.add(DoubleProperty('width', width, defaultValue: null));
|
||||
properties.add(DoubleProperty('height', height, defaultValue: null));
|
||||
properties.add(EnumProperty<BoxFit>('fit', fit, defaultValue: null));
|
||||
@ -396,7 +408,9 @@ class _LottieBuilderState extends State<LottieBuilder> {
|
||||
future: _loadingFuture,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasError) {
|
||||
if (kDebugMode) {
|
||||
if (widget.errorBuilder != null) {
|
||||
return widget.errorBuilder(context, snapshot.error);
|
||||
} else if (kDebugMode) {
|
||||
return ErrorWidget(snapshot.error);
|
||||
}
|
||||
}
|
||||
@ -435,3 +449,10 @@ class _LottieBuilderState extends State<LottieBuilder> {
|
||||
'loadingFuture', _loadingFuture));
|
||||
}
|
||||
}
|
||||
|
||||
/// Signature used by [Lottie.errorBuilder] to create a replacement widget to
|
||||
/// render instead of the Lottie animation.
|
||||
typedef LottieErrorWidgetBuilder = Widget Function(
|
||||
BuildContext context,
|
||||
Object error,
|
||||
);
|
||||
|
@ -18,6 +18,9 @@ class LottieDrawable {
|
||||
bool _isDirty = true;
|
||||
final bool enableMergePaths;
|
||||
|
||||
/// Gives a suggestion whether to paint with anti-aliasing, or not. Default is true.
|
||||
bool antiAliasingSuggested = true;
|
||||
|
||||
LottieDrawable(this.composition,
|
||||
{LottieDelegates delegates, bool enableMergePaths})
|
||||
: size = Size(composition.bounds.width.toDouble(),
|
||||
|
@ -5,13 +5,14 @@ import '../../animation/keyframe/value_callback_keyframe_animation.dart';
|
||||
import '../../lottie_drawable.dart';
|
||||
import '../../lottie_property.dart';
|
||||
import '../../utils.dart';
|
||||
import '../../utils/path_factory.dart';
|
||||
import '../../value/lottie_value_callback.dart';
|
||||
import 'base_layer.dart';
|
||||
import 'layer.dart';
|
||||
|
||||
class SolidLayer extends BaseLayer {
|
||||
final Paint paint = Paint()..style = PaintingStyle.fill;
|
||||
final Path path = Path();
|
||||
final Path path = PathFactory.create();
|
||||
BaseKeyframeAnimation<ColorFilter, ColorFilter> /*?*/ _colorFilterAnimation;
|
||||
|
||||
SolidLayer(LottieDrawable lottieDrawable, Layer layerModel)
|
||||
|
@ -1,6 +1,7 @@
|
||||
import 'dart:math';
|
||||
import 'dart:ui';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'path_factory.dart';
|
||||
|
||||
Path dashPath(
|
||||
Path source, {
|
||||
@ -14,7 +15,7 @@ Path dashPath(
|
||||
}
|
||||
phase ??= 0;
|
||||
|
||||
var dest = Path();
|
||||
var dest = PathFactory.create();
|
||||
for (final metric in source.computeMetrics()) {
|
||||
for (var dash in _dashes(metric.length, intervals, phase)) {
|
||||
dest.addPath(metric.extractPath(dash.left, dash.right), Offset.zero);
|
||||
|
@ -1,6 +1,6 @@
|
||||
class MeanCalculator {
|
||||
double _sum;
|
||||
int _n;
|
||||
double _sum = 0;
|
||||
int _n = 0;
|
||||
|
||||
double get mean => _n == 0 ? 0 : _sum / _n;
|
||||
|
||||
|
195
lib/src/utils/path_factory.dart
Normal file
@ -0,0 +1,195 @@
|
||||
import 'dart:typed_data';
|
||||
import 'dart:ui';
|
||||
|
||||
class PathFactory {
|
||||
static Path create() {
|
||||
return Path();
|
||||
}
|
||||
}
|
||||
|
||||
class DebugPath extends Path {
|
||||
void _log(String methodName) {
|
||||
print('Path.$methodName');
|
||||
}
|
||||
|
||||
@override
|
||||
void addArc(Rect oval, double startAngle, double sweepAngle) {
|
||||
_log('addArc');
|
||||
super.addArc(oval, startAngle, sweepAngle);
|
||||
}
|
||||
|
||||
@override
|
||||
void addOval(Rect oval) {
|
||||
_log('addOval');
|
||||
super.addOval(oval);
|
||||
}
|
||||
|
||||
@override
|
||||
void addPath(Path path, Offset offset, {Float64List matrix4}) {
|
||||
_log('addPath');
|
||||
super.addPath(path, offset, matrix4: matrix4);
|
||||
}
|
||||
|
||||
@override
|
||||
void addPolygon(List<Offset> points, bool close) {
|
||||
_log('addPolygon');
|
||||
super.addPolygon(points, close);
|
||||
}
|
||||
|
||||
@override
|
||||
void addRRect(RRect rrect) {
|
||||
_log('addRRect');
|
||||
super.addRRect(rrect);
|
||||
}
|
||||
|
||||
@override
|
||||
void addRect(Rect rect) {
|
||||
_log('addRect');
|
||||
super.addRect(rect);
|
||||
}
|
||||
|
||||
@override
|
||||
void arcTo(
|
||||
Rect rect, double startAngle, double sweepAngle, bool forceMoveTo) {
|
||||
_log('arcTo');
|
||||
super.arcTo(rect, startAngle, sweepAngle, forceMoveTo);
|
||||
}
|
||||
|
||||
@override
|
||||
void arcToPoint(Offset arcEnd,
|
||||
{Radius radius = Radius.zero,
|
||||
double rotation = 0.0,
|
||||
bool largeArc = false,
|
||||
bool clockwise = true}) {
|
||||
_log('arcToPoint');
|
||||
super.arcToPoint(arcEnd,
|
||||
radius: radius,
|
||||
rotation: rotation,
|
||||
largeArc: largeArc,
|
||||
clockwise: clockwise);
|
||||
}
|
||||
|
||||
@override
|
||||
void close() {
|
||||
_log('close');
|
||||
super.close();
|
||||
}
|
||||
|
||||
@override
|
||||
PathMetrics computeMetrics({bool forceClosed = false}) {
|
||||
_log('computeMetrics');
|
||||
return super.computeMetrics();
|
||||
}
|
||||
|
||||
@override
|
||||
void conicTo(double x1, double y1, double x2, double y2, double w) {
|
||||
_log('conicTo');
|
||||
super.conicTo(x1, y1, x2, y2, w);
|
||||
}
|
||||
|
||||
@override
|
||||
bool contains(Offset point) {
|
||||
_log('contains');
|
||||
return super.contains(point);
|
||||
}
|
||||
|
||||
@override
|
||||
void cubicTo(
|
||||
double x1, double y1, double x2, double y2, double x3, double y3) {
|
||||
_log('cubicTo');
|
||||
super.cubicTo(x1, y1, x2, y2, x3, y3);
|
||||
}
|
||||
|
||||
@override
|
||||
void extendWithPath(Path path, Offset offset, {Float64List matrix4}) {
|
||||
_log('extendWithPath');
|
||||
super.extendWithPath(path, offset, matrix4: matrix4);
|
||||
}
|
||||
|
||||
@override
|
||||
Rect getBounds() {
|
||||
_log('getBounds');
|
||||
return super.getBounds();
|
||||
}
|
||||
|
||||
@override
|
||||
void lineTo(double x, double y) {
|
||||
_log('lineTo');
|
||||
super.lineTo(x, y);
|
||||
}
|
||||
|
||||
@override
|
||||
void moveTo(double x, double y) {
|
||||
_log('moveTo');
|
||||
super.moveTo(x, y);
|
||||
}
|
||||
|
||||
@override
|
||||
void quadraticBezierTo(double x1, double y1, double x2, double y2) {
|
||||
_log('quadraticBezierTo');
|
||||
super.quadraticBezierTo(x1, y1, x2, y2);
|
||||
}
|
||||
|
||||
@override
|
||||
void relativeArcToPoint(Offset arcEndDelta,
|
||||
{Radius radius = Radius.zero,
|
||||
double rotation = 0.0,
|
||||
bool largeArc = false,
|
||||
bool clockwise = true}) {
|
||||
_log('relativeArcToPoint');
|
||||
super.relativeArcToPoint(arcEndDelta,
|
||||
radius: radius,
|
||||
rotation: rotation,
|
||||
largeArc: largeArc,
|
||||
clockwise: clockwise);
|
||||
}
|
||||
|
||||
@override
|
||||
void relativeConicTo(double x1, double y1, double x2, double y2, double w) {
|
||||
_log('relativeConicTo');
|
||||
super.relativeConicTo(x1, y1, x2, y2, w);
|
||||
}
|
||||
|
||||
@override
|
||||
void relativeCubicTo(
|
||||
double x1, double y1, double x2, double y2, double x3, double y3) {
|
||||
_log('relativeCubicTo');
|
||||
super.relativeCubicTo(x1, y1, x2, y2, x3, y3);
|
||||
}
|
||||
|
||||
@override
|
||||
void relativeLineTo(double dx, double dy) {
|
||||
_log('relativeLineTo');
|
||||
super.relativeLineTo(dx, dy);
|
||||
}
|
||||
|
||||
@override
|
||||
void relativeMoveTo(double dx, double dy) {
|
||||
_log('relativeMoveTo');
|
||||
super.relativeMoveTo(dx, dy);
|
||||
}
|
||||
|
||||
@override
|
||||
void relativeQuadraticBezierTo(double x1, double y1, double x2, double y2) {
|
||||
_log('relativeQuadraticBezierTo');
|
||||
super.relativeQuadraticBezierTo(x1, y1, x2, y2);
|
||||
}
|
||||
|
||||
@override
|
||||
void reset() {
|
||||
_log('reset');
|
||||
super.reset();
|
||||
}
|
||||
|
||||
@override
|
||||
Path shift(Offset offset) {
|
||||
_log('shift');
|
||||
return super.shift(offset);
|
||||
}
|
||||
|
||||
@override
|
||||
Path transform(Float64List matrix4) {
|
||||
_log('transform');
|
||||
return super.transform(matrix4);
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
import 'dart:ui';
|
||||
import 'package:flutter/animation.dart';
|
||||
import 'path_factory.dart';
|
||||
|
||||
class PathInterpolator extends Curve {
|
||||
/// Governs the accuracy of the approximation of the {@link Path}.
|
||||
@ -72,7 +73,7 @@ class PathInterpolator extends Curve {
|
||||
|
||||
static Path _createCubic(
|
||||
double controlX1, double controlY1, double controlX2, double controlY2) {
|
||||
final path = Path();
|
||||
final path = PathFactory.create();
|
||||
path.moveTo(0.0, 0.0);
|
||||
path.cubicTo(controlX1, controlY1, controlX2, controlY2, 1.0, 1.0);
|
||||
return path;
|
||||
|
@ -4,11 +4,12 @@ import '../animation/content/trim_path_content.dart';
|
||||
import '../l.dart';
|
||||
import '../utils.dart';
|
||||
import 'misc.dart';
|
||||
import 'path_factory.dart';
|
||||
|
||||
class Utils {
|
||||
static Path createPath(
|
||||
Offset startPoint, Offset endPoint, Offset cp1, Offset cp2) {
|
||||
var path = Path();
|
||||
var path = PathFactory.create();
|
||||
path.moveTo(startPoint.dx, startPoint.dy);
|
||||
|
||||
if (cp1 != null &&
|
||||
|
42
pubspec.lock
@ -14,7 +14,7 @@ packages:
|
||||
name: analyzer
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.39.15"
|
||||
version: "0.39.14"
|
||||
archive:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -35,28 +35,28 @@ packages:
|
||||
name: async
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.4.2"
|
||||
version: "2.5.0-nullsafety.1"
|
||||
boolean_selector:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: boolean_selector
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.0"
|
||||
version: "2.1.0-nullsafety.1"
|
||||
characters:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: characters
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.0-nullsafety"
|
||||
version: "1.1.0-nullsafety.3"
|
||||
charcode:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: charcode
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.3"
|
||||
version: "1.2.0-nullsafety.1"
|
||||
cli_util:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -70,14 +70,14 @@ packages:
|
||||
name: clock
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.1"
|
||||
version: "1.1.0-nullsafety.1"
|
||||
collection:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: collection
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.15.0-nullsafety"
|
||||
version: "1.15.0-nullsafety.3"
|
||||
convert:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -112,7 +112,7 @@ packages:
|
||||
name: fake_async
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
version: "1.2.0-nullsafety.1"
|
||||
flutter:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
@ -157,14 +157,14 @@ packages:
|
||||
name: matcher
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.12.8"
|
||||
version: "0.12.10-nullsafety.1"
|
||||
meta:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: meta
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.3.0-nullsafety"
|
||||
version: "1.3.0-nullsafety.3"
|
||||
mockito:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
@ -199,14 +199,14 @@ packages:
|
||||
name: path
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.7.0"
|
||||
version: "1.8.0-nullsafety.1"
|
||||
pedantic:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: pedantic
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.9.2"
|
||||
version: "1.9.0"
|
||||
pub_semver:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -225,56 +225,56 @@ packages:
|
||||
name: source_span
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.7.0"
|
||||
version: "1.8.0-nullsafety.2"
|
||||
stack_trace:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: stack_trace
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.9.5"
|
||||
version: "1.10.0-nullsafety.1"
|
||||
stream_channel:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: stream_channel
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.0"
|
||||
version: "2.1.0-nullsafety.1"
|
||||
string_scanner:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: string_scanner
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.5"
|
||||
version: "1.1.0-nullsafety.1"
|
||||
term_glyph:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: term_glyph
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
version: "1.2.0-nullsafety.1"
|
||||
test_api:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_api
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.2.17"
|
||||
version: "0.2.19-nullsafety.2"
|
||||
typed_data:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: typed_data
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.3.0-nullsafety"
|
||||
version: "1.3.0-nullsafety.3"
|
||||
vector_math:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: vector_math
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.0-nullsafety"
|
||||
version: "2.1.0-nullsafety.3"
|
||||
watcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -290,4 +290,4 @@ packages:
|
||||
source: hosted
|
||||
version: "2.2.1"
|
||||
sdks:
|
||||
dart: ">=2.9.0-18.0 <2.9.0"
|
||||
dart: ">=2.10.0-110 <2.11.0"
|
||||
|
@ -21,7 +21,7 @@ dependencies:
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
analyzer:
|
||||
dart_style:
|
||||
analyzer: 0.39.14
|
||||
dart_style: 1.3.6
|
||||
mockito: ^4.0.0
|
||||
yaml:
|
||||
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 38 KiB |
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 133 KiB After Width: | Height: | Size: 133 KiB |