Skip to content

Commit

Permalink
Flutter 3.27 (#389)
Browse files Browse the repository at this point in the history
  • Loading branch information
xvrh authored Dec 12, 2024
1 parent 7e4d1d3 commit 61756b6
Show file tree
Hide file tree
Showing 68 changed files with 101 additions and 95 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 3.3.0
- Requires Flutter 3.27 and fix lints.

## 3.2.1
- Add conditional imports to prevent importing `dart:io` on Web targets

Expand Down
2 changes: 1 addition & 1 deletion example/lib/examples/draw_cache.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:flutter/material.dart' hide Image;
import 'package:flutter/material.dart' as material;
import 'package:lottie/lottie.dart';

/// This example shows how to cache the animation as a List<Image>.
/// This example shows how to cache the animation as a `List<Image>`.
/// After the initial cache of each frame, drawing the animation is almost free
/// in term of CPU usage.
/// The animation will run at a specific framerate (not FrameRate.max) and specific size
Expand Down
2 changes: 1 addition & 1 deletion example/lib/main_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class _Item extends StatelessWidget {
borderRadius: const BorderRadius.all(Radius.circular(10)),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.1),
color: Colors.black.withValues(alpha: 0.1),
offset: const Offset(2, 2),
blurRadius: 5)
]),
Expand Down
52 changes: 26 additions & 26 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ packages:
dependency: "direct main"
description:
name: collection
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf
url: "https://pub.dev"
source: hosted
version: "1.18.0"
version: "1.19.0"
convert:
dependency: transitive
description:
Expand Down Expand Up @@ -119,26 +119,26 @@ packages:
dependency: transitive
description:
name: http_parser
sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b"
sha256: "76d306a1c3afb33fe82e2bbacad62a61f409b5634c915fceb0d799de1a913360"
url: "https://pub.dev"
source: hosted
version: "4.0.2"
version: "4.1.1"
leak_tracker:
dependency: transitive
description:
name: leak_tracker
sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05"
sha256: "7bb2830ebd849694d1ec25bf1f44582d6ac531a57a365a803a6034ff751d2d06"
url: "https://pub.dev"
source: hosted
version: "10.0.5"
version: "10.0.7"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806"
sha256: "9491a714cca3667b60b5c420da8217e6de0d1ba7a5ec322fab01758f6998f379"
url: "https://pub.dev"
source: hosted
version: "3.0.5"
version: "3.0.8"
leak_tracker_testing:
dependency: transitive
description:
Expand All @@ -151,10 +151,10 @@ packages:
dependency: transitive
description:
name: lints
sha256: "3315600f3fb3b135be672bf4a178c55f274bebe368325ae18462c89ac1e3b413"
sha256: "4a16b3f03741e1252fda5de3ce712666d010ba2122f8e912c94f9f7b90e1a4c3"
url: "https://pub.dev"
source: hosted
version: "5.0.0"
version: "5.1.0"
logging:
dependency: "direct main"
description:
Expand All @@ -169,7 +169,7 @@ packages:
path: ".."
relative: true
source: path
version: "3.2.1"
version: "3.3.0"
matcher:
dependency: transitive
description:
Expand Down Expand Up @@ -222,10 +222,10 @@ packages:
dependency: transitive
description:
name: path_provider_android
sha256: "8c4967f8b7cb46dc914e178daa29813d83ae502e0529d7b0478330616a691ef7"
sha256: "4adf4fd5423ec60a29506c76581bc05854c55e3a0b72d35bb28d661c9686edf2"
url: "https://pub.dev"
source: hosted
version: "2.2.14"
version: "2.2.15"
path_provider_foundation:
dependency: transitive
description:
Expand Down Expand Up @@ -278,10 +278,10 @@ packages:
dependency: "direct dev"
description:
name: shelf
sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4
sha256: e7dd780a7ffb623c57850b33f43309312fc863fb6aa3d276a754bb299839ef12
url: "https://pub.dev"
source: hosted
version: "1.4.1"
version: "1.4.2"
shelf_static:
dependency: "direct dev"
description:
Expand All @@ -294,7 +294,7 @@ packages:
dependency: transitive
description: flutter
source: sdk
version: "0.0.99"
version: "0.0.0"
source_span:
dependency: transitive
description:
Expand All @@ -307,10 +307,10 @@ packages:
dependency: transitive
description:
name: stack_trace
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
sha256: "9f47fd3630d76be3ab26f0ee06d213679aa425996925ff3feffdec504931c377"
url: "https://pub.dev"
source: hosted
version: "1.11.1"
version: "1.12.0"
stream_channel:
dependency: transitive
description:
Expand All @@ -323,10 +323,10 @@ packages:
dependency: transitive
description:
name: string_scanner
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
sha256: "688af5ed3402a4bde5b3a6c15fd768dbf2621a614950b17f04626c431ab3c4c3"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
version: "1.3.0"
term_glyph:
dependency: transitive
description:
Expand All @@ -339,10 +339,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
sha256: "664d3a9a64782fcdeb83ce9c6b39e78fd2971d4e37827b9b06c3aa1edc5e760c"
url: "https://pub.dev"
source: hosted
version: "0.7.2"
version: "0.7.3"
typed_data:
dependency: transitive
description:
Expand All @@ -363,10 +363,10 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
sha256: f6be3ed8bd01289b34d679c2b62226f63c0e69f9fd2e50a6b3c1c729a961041b
url: "https://pub.dev"
source: hosted
version: "14.2.5"
version: "14.3.0"
web:
dependency: transitive
description:
Expand All @@ -384,5 +384,5 @@ packages:
source: hosted
version: "1.1.0"
sdks:
dart: ">=3.5.0 <4.0.0"
flutter: ">=3.24.0"
dart: ">=3.6.0 <4.0.0"
flutter: ">=3.27.0"
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ publish_to: none
version: 2.7.0+1

environment:
sdk: "^3.2.0"
sdk: "^3.6.0"

dependencies:
collection:
Expand Down
3 changes: 2 additions & 1 deletion lib/src/animation/content/stroke_content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ class StrokeContent extends BaseStrokeContent {
if (_hidden) {
return;
}
paint.color = _colorAnimation.value.withAlpha(paint.color.alpha);
paint.color =
_colorAnimation.value.withAlpha((paint.color.a * 255).toInt());
if (_colorFilterAnimation != null) {
paint.colorFilter = _colorFilterAnimation!.value;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/src/animation/keyframe/base_keyframe_animation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import '../../l.dart';
import '../../value/keyframe.dart';
import '../../value/lottie_value_callback.dart';

/// @param <K> Keyframe type
/// @param <A> Animation type
/// @param K Keyframe type
/// @param A Animation type
abstract class BaseKeyframeAnimation<K extends Object, A extends Object?> {
// This is not a Set because we don't want to create an iterator object on every setProgress.
final listeners = <void Function()>[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ class DropShadowKeyframeAnimation {
if (callback != null) {
_color.setValueCallback(_createCallback(
callback, (c) => c?.color ?? const Color(0xff000000)));
_opacity.setValueCallback(
_createCallback(callback, (c) => c?.color.alpha.toDouble() ?? 255));
_opacity
.setValueCallback(_createCallback(callback, (c) => c?.color.a ?? 1));
_direction.setValueCallback(
_createCallback(callback, (c) => c?.direction ?? 0));
_distance
Expand Down
10 changes: 4 additions & 6 deletions lib/src/model/layer/solid_layer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,17 @@ class SolidLayer extends BaseLayer {
@override
void drawLayer(Canvas canvas, Matrix4 parentMatrix,
{required int parentAlpha}) {
var backgroundAlpha = layerModel.solidColor.alpha;
var backgroundAlpha = layerModel.solidColor.a;
if (backgroundAlpha == 0) {
return;
}

paint.color = _colorAnimation?.value ?? layerModel.solidColor;

var opacity = transform.opacity?.value ?? 100;
var alpha = (parentAlpha /
255.0 *
(backgroundAlpha / 255.0 * opacity / 100.0) *
255.0)
.round();
var alpha =
(parentAlpha / 255.0 * (backgroundAlpha * opacity / 100.0) * 255.0)
.round();
paint.setAlpha(alpha);

if (_colorFilterAnimation != null) {
Expand Down
9 changes: 5 additions & 4 deletions lib/src/model/layer/text_layer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class TextLayer extends BaseLayer {
} else {
fillPaintColor = documentData.color;
}
_fillPaint.color = fillPaintColor.withAlpha(_fillPaint.color.alpha);
_fillPaint.color = fillPaintColor.withValues(alpha: _fillPaint.color.a);

Color strokePaintColor;
if (_strokeColorCallbackAnimation != null) {
Expand All @@ -130,7 +130,8 @@ class TextLayer extends BaseLayer {
} else {
strokePaintColor = documentData.strokeColor;
}
_strokePaint.color = strokePaintColor.withAlpha(_strokePaint.color.alpha);
_strokePaint.color =
strokePaintColor.withValues(alpha: _strokePaint.color.a);

var opacity = transform.opacity?.value ?? 100;
var alpha = opacity * 255 / 100 * parentAlpha ~/ 255;
Expand Down Expand Up @@ -418,7 +419,7 @@ class TextLayer extends BaseLayer {
}

void _drawGlyph(Path path, Paint paint, Canvas canvas) {
if (paint.color.alpha == 0) {
if (paint.color.a == 0) {
return;
}
if (paint.style == PaintingStyle.stroke && paint.strokeWidth == 0) {
Expand All @@ -440,7 +441,7 @@ class TextLayer extends BaseLayer {

void _drawCharacter(
String character, TextStyle textStyle, Paint paint, Canvas canvas) {
if (paint.color.alpha == 0) {
if (paint.color.a == 0) {
return;
}
if (paint.style == PaintingStyle.stroke && paint.strokeWidth == 0) {
Expand Down
1 change: 0 additions & 1 deletion lib/src/parser/drop_shadow_effect_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ class DropShadowEffectParser {
_radius = AnimatableValueParser.parseFloat(reader, composition);
default:
reader.skipValue();
break;
}
default:
reader.skipName();
Expand Down
12 changes: 6 additions & 6 deletions lib/src/parser/gradient_color_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class GradientColorParser {
continue;
}
if (i == colorStopPositions.length - 1 && position >= colorStopPosition) {
return colorStopColors[i].withOpacity(opacity);
return colorStopColors[i].withValues(alpha: opacity);
}
// We found the position in which position is between i - 1 and i.
var distanceBetweenColors =
Expand All @@ -171,9 +171,9 @@ class GradientColorParser {
var percentage = distanceToLowerColor / distanceBetweenColors;
var upperColor = colorStopColors[i];
var lowerColor = colorStopColors[i - 1];
return GammaEvaluator.evaluate(
percentage, lowerColor.withOpacity(1), upperColor.withOpacity(1))
.withOpacity(opacity);
return GammaEvaluator.evaluate(percentage,
lowerColor.withValues(alpha: 1), upperColor.withValues(alpha: 1))
.withValues(alpha: opacity);
}
throw Exception('Unreachable code.');
}
Expand All @@ -182,7 +182,7 @@ class GradientColorParser {
List<double> opacityStopPositions, List<double> opacityStopOpacities) {
if (opacityStopOpacities.length < 2 ||
position <= opacityStopPositions[0]) {
return color.withOpacity(opacityStopOpacities[0]);
return color.withValues(alpha: opacityStopOpacities[0]);
}
for (var i = 1; i < opacityStopPositions.length; i++) {
var opacityStopPosition = opacityStopPositions[i];
Expand All @@ -202,7 +202,7 @@ class GradientColorParser {
opacity = lerpDouble(
opacityStopOpacities[i - 1], opacityStopOpacities[i], percentage)!;
}
return color.withOpacity(opacity);
return color.withValues(alpha: opacity);
}
throw Exception('Unreachable code.');
}
Expand Down
2 changes: 2 additions & 0 deletions lib/src/parser/moshi/json_reader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import 'buffer.dart';
import 'json_scope.dart';
import 'json_utf8_reader.dart';

// ignore_for_file: unintended_html_in_doc_comment

/// Reads a JSON (<a href="http://www.ietf.org/rfc/rfc7159.txt">RFC 7159</a>)
/// encoded value as a stream of tokens. This stream includes both literal
/// values (strings, numbers, booleans, and nulls) as well as the begin and
Expand Down
16 changes: 8 additions & 8 deletions lib/src/utils/gamma_evaluator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ class GammaEvaluator {
return endColor;
}

var startA = startColor.alpha / 255.0;
var startR = startColor.red / 255.0;
var startG = startColor.green / 255.0;
var startB = startColor.blue / 255.0;
var startA = startColor.a;
var startR = startColor.r;
var startG = startColor.g;
var startB = startColor.b;

var endA = endColor.alpha / 255.0;
var endR = endColor.red / 255.0;
var endG = endColor.green / 255.0;
var endB = endColor.blue / 255.0;
var endA = endColor.a;
var endR = endColor.r;
var endG = endColor.g;
var endB = endColor.b;

// convert from sRGB to linear
startR = _eocfSRgb(startR);
Expand Down
Loading

0 comments on commit 61756b6

Please sign in to comment.