Compare commits

..

5 Commits

452 changed files with 394 additions and 412 deletions

View File

@ -34,7 +34,7 @@ jobs:
&& exit 1)
shell: bash
build_web_version:
name: Check that the web version compile
name: Check that the web version can compile
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

View File

@ -1,3 +1,31 @@
## [2.0.0]
- **Breaking change**: the lottie widget will be smaller if it relies on the intrinsic size of the composition.
Previously the lottie parser was automatically multiplying the size of the composition by `window.devicePixelRatio`.
This was incorrect as it results in a widget of a different size depending on the pixel ratio of the monitor.
Furthermore, it created some bugs when the property `window.devicePixelRatio` was not available immediately at the start
of the app (on Android release builds).
The code can be adapted to specify explicitly the size of the animation with `width`, `height` and `fit` properties.
```dart
Scaffold(
body: Center(
child: Lottie.asset(
'assets/LottieLogo1.json',
height: 800,
fit: BoxFit.contain,
),
),
);
```
## [1.4.3]
- Fixed some lints with Flutter 3.3.
## [1.4.2]
- Use `FilterQuality.low` as default to draw image layers.
## [1.4.1]
- Allow `AlignmentGeometry` for `alignment`.

View File

@ -23,7 +23,7 @@ import 'package:lottie/lottie.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
const MyApp({super.key});
@override
Widget build(BuildContext context) {
@ -61,7 +61,7 @@ import 'package:lottie/lottie.dart';
void main() => runApp(const MyApp());
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
@ -136,7 +136,7 @@ This example shows how to load and parse a Lottie composition from a json file.
```dart
class MyWidget extends StatefulWidget {
const MyWidget({Key? key}) : super(key: key);
const MyWidget({super.key});
@override
State<MyWidget> createState() => _MyWidgetState();
@ -182,7 +182,7 @@ a specific position and size.
class CustomDrawer extends StatelessWidget {
final LottieComposition composition;
const CustomDrawer(this.composition, {Key? key}) : super(key: key);
const CustomDrawer(this.composition, {super.key});
@override
Widget build(BuildContext context) {

View File

@ -10,14 +10,16 @@ linter:
always_declare_return_types: true
avoid_dynamic_calls: true
avoid_escaping_inner_quotes: true
avoid_returning_null_for_future: true
avoid_setters_without_getters: true
cancel_subscriptions: true
cast_nullable_to_non_nullable: true
close_sinks: true
no_adjacent_strings_in_list: true
no_default_cases: true
omit_local_variable_types: true
only_throw_errors: true
prefer_interpolation_to_compose_strings: true
prefer_relative_imports: true
prefer_single_quotes: true
sort_child_properties_last: true
sort_pub_dependencies: true
@ -27,3 +29,4 @@ linter:
unnecessary_statements: true
unsafe_html: true
use_raw_strings: true
use_super_parameters: true

View File

@ -9,7 +9,7 @@ import 'package:lottie/lottie.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
const MyApp({super.key});
@override
Widget build(BuildContext context) {

View File

@ -5,7 +5,7 @@ import 'package:lottie/lottie.dart';
void main() => runApp(const App());
class App extends StatelessWidget {
const App({Key? key}) : super(key: key);
const App({super.key});
@override
Widget build(BuildContext context) {

View File

@ -6,7 +6,7 @@ void main() async {
}
class App extends StatelessWidget {
const App({Key? key}) : super(key: key);
const App({super.key});
@override
Widget build(BuildContext context) {

View File

@ -4,7 +4,7 @@ import 'package:lottie/lottie.dart';
void main() => runApp(const MyApp());
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();

View File

@ -12,7 +12,7 @@ import 'package:lottie/lottie.dart';
void main() => runApp(const MyApp());
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();

View File

@ -4,7 +4,7 @@ import 'package:lottie/lottie.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
const MyApp({super.key});
@override
Widget build(BuildContext context) {

View File

@ -5,7 +5,7 @@ import 'package:lottie/lottie.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
const MyApp({super.key});
@override
Widget build(BuildContext context) {
@ -18,7 +18,7 @@ class MyApp extends StatelessWidget {
}
class MyWidget extends StatefulWidget {
const MyWidget({Key? key}) : super(key: key);
const MyWidget({super.key});
@override
State<MyWidget> createState() => _MyWidgetState();
@ -60,7 +60,7 @@ class _MyWidgetState extends State<MyWidget> {
class CustomDrawer extends StatelessWidget {
final LottieComposition composition;
const CustomDrawer(this.composition, {Key? key}) : super(key: key);
const CustomDrawer(this.composition, {super.key});
@override
Widget build(BuildContext context) {

View File

@ -5,7 +5,7 @@ import 'package:lottie/lottie.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
const MyApp({super.key});
@override
Widget build(BuildContext context) {
@ -19,7 +19,7 @@ class MyApp extends StatelessWidget {
//--- example
class MyWidget extends StatefulWidget {
const MyWidget({Key? key}) : super(key: key);
const MyWidget({super.key});
@override
State<MyWidget> createState() => _MyWidgetState();

View File

@ -4,7 +4,7 @@ import 'package:lottie/lottie.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
const MyApp({super.key});
@override
Widget build(BuildContext context) {

View File

@ -7,7 +7,7 @@ void main() async {
}
class App extends StatefulWidget {
const App({Key? key}) : super(key: key);
const App({super.key});
@override
State<App> createState() => _AppState();

View File

@ -7,7 +7,7 @@ void main() async {
}
class App extends StatefulWidget {
const App({Key? key}) : super(key: key);
const App({super.key});
@override
State<App> createState() => _AppState();

View File

@ -4,7 +4,7 @@ import 'package:lottie/lottie.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
const MyApp({super.key});
@override
Widget build(BuildContext context) {

View File

@ -4,7 +4,7 @@ import 'package:lottie/lottie.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
const MyApp({super.key});
@override
Widget build(BuildContext context) {

View File

@ -6,7 +6,7 @@ void main() async {
}
class App extends StatefulWidget {
const App({Key? key}) : super(key: key);
const App({super.key});
@override
State<App> createState() => _AppState();

View File

@ -9,7 +9,7 @@ void main() async {
}
class App extends StatefulWidget {
const App({Key? key}) : super(key: key);
const App({super.key});
@override
State<App> createState() => _AppState();
@ -48,7 +48,7 @@ class _AppState extends State<App> with TickerProviderStateMixin {
class _LottieDetails extends StatefulWidget {
final LottieComposition composition;
const _LottieDetails(this.composition, {Key? key}) : super(key: key);
const _LottieDetails(this.composition);
@override
_LottieDetailsState createState() => _LottieDetailsState();

View File

@ -4,7 +4,7 @@ import 'package:lottie/lottie.dart';
void main() => runApp(const MyApp());
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();

View File

@ -12,7 +12,7 @@ void main() async {
}
class App extends StatefulWidget {
const App({Key? key}) : super(key: key);
const App({super.key});
@override
State<App> createState() => _AppState();

View File

@ -10,7 +10,7 @@ import 'package:path_provider/path_provider.dart';
void main() => runApp(const MyApp());
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();

View File

@ -4,7 +4,7 @@ import 'package:lottie/lottie.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
const MyApp({super.key});
@override
Widget build(BuildContext context) {

View File

@ -4,7 +4,7 @@ import 'package:lottie/lottie.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
const MyApp({super.key});
@override
Widget build(BuildContext context) {

View File

@ -14,7 +14,7 @@ void main() {
}
class App extends StatelessWidget {
const App({Key? key}) : super(key: key);
const App({super.key});
@override
Widget build(BuildContext context) {
@ -24,8 +24,8 @@ class App extends StatelessWidget {
appBar: AppBar(
title: const Text('Lottie Flutter'),
),
body: Scrollbar(
child: GridView.builder(
body: GridView.builder(
primary: true,
itemCount: files.length,
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 4),
@ -41,6 +41,7 @@ class App extends StatelessWidget {
child: _Item(
child: Lottie.asset(
assetName,
fit: BoxFit.contain,
onWarning: (w) => _logger.info('$assetName - $w'),
frameBuilder: (context, child, composition) {
return AnimatedOpacity(
@ -56,7 +57,6 @@ class App extends StatelessWidget {
},
),
),
),
);
}
}
@ -64,7 +64,7 @@ class App extends StatelessWidget {
class _Item extends StatelessWidget {
final Widget child;
const _Item({Key? key, required this.child}) : super(key: key);
const _Item({required this.child});
@override
Widget build(BuildContext context) {
@ -89,7 +89,7 @@ class _Item extends StatelessWidget {
class Detail extends StatefulWidget {
final String assetName;
const Detail(this.assetName, {Key? key}) : super(key: key);
const Detail(this.assetName, {super.key});
@override
State<Detail> createState() => _DetailState();

View File

@ -13,7 +13,7 @@ void main() async {
class App extends StatelessWidget {
final LottieComposition composition;
const App({Key? key, required this.composition}) : super(key: key);
const App({super.key, required this.composition});
@override
Widget build(BuildContext context) {
@ -103,8 +103,7 @@ class _Lottie extends StatefulWidget {
final AlignmentGeometry? alignment;
const _Lottie(this.composition,
{Key? key, this.width, this.height, this.fit, this.alignment})
: super(key: key);
{this.width, this.height, this.fit, this.alignment});
@override
__LottieState createState() => __LottieState();

View File

@ -6,7 +6,7 @@ void main() async {
}
class App extends StatelessWidget {
const App({Key? key}) : super(key: key);
const App({super.key});
@override
Widget build(BuildContext context) {

View File

@ -6,7 +6,7 @@ void main() async {
}
class App extends StatelessWidget {
const App({Key? key}) : super(key: key);
const App({super.key});
@override
Widget build(BuildContext context) {

View File

@ -0,0 +1,11 @@
//
// Generated file. Do not edit.
//
// clang-format off
#include "generated_plugin_registrant.h"
void fl_register_plugins(FlPluginRegistry* registry) {
}

View File

@ -0,0 +1,15 @@
//
// Generated file. Do not edit.
//
// clang-format off
#ifndef GENERATED_PLUGIN_REGISTRANT_
#define GENERATED_PLUGIN_REGISTRANT_
#include <flutter_linux/flutter_linux.h>
// Registers Flutter plugins.
void fl_register_plugins(FlPluginRegistry* registry);
#endif // GENERATED_PLUGIN_REGISTRANT_

View File

@ -0,0 +1,23 @@
#
# Generated file, do not edit.
#
list(APPEND FLUTTER_PLUGIN_LIST
)
list(APPEND FLUTTER_FFI_PLUGIN_LIST
)
set(PLUGIN_BUNDLED_LIBRARIES)
foreach(plugin ${FLUTTER_PLUGIN_LIST})
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin})
target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
endforeach(plugin)
foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin})
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
endforeach(ffi_plugin)

View File

@ -14,8 +14,8 @@ EXTERNAL SOURCES:
:path: Flutter/ephemeral/.symlinks/plugins/path_provider_macos/macos
SPEC CHECKSUMS:
FlutterMacOS: 57701585bf7de1b3fc2bb61f6378d73bbdea8424
path_provider_macos: 160cab0d5461f0c0e02995469a98f24bdb9a3f1f
FlutterMacOS: ae6af50a8ea7d6103d888583d46bd8328a7e9811
path_provider_macos: 3c0c3b4b0d4a76d2bf989a913c2de869c5641a19
PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c

View File

@ -7,14 +7,14 @@ packages:
name: archive
url: "https://pub.dartlang.org"
source: hosted
version: "3.3.1"
version: "3.3.2"
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.8.2"
version: "2.9.0"
boolean_selector:
dependency: transitive
description:
@ -28,21 +28,14 @@ packages:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.1"
version: "1.2.1"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.1.1"
collection:
dependency: transitive
description:
@ -63,7 +56,7 @@ packages:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "1.3.1"
ffi:
dependency: transitive
description:
@ -77,7 +70,7 @@ packages:
name: file
url: "https://pub.dartlang.org"
source: hosted
version: "6.1.2"
version: "6.1.4"
flutter:
dependency: "direct main"
description: flutter
@ -115,63 +108,63 @@ packages:
name: http
url: "https://pub.dartlang.org"
source: hosted
version: "0.13.4"
version: "0.13.5"
http_parser:
dependency: transitive
description:
name: http_parser
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.1"
version: "4.0.2"
lints:
dependency: transitive
description:
name: lints
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.0.1"
logging:
dependency: "direct main"
description:
name: logging
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.2"
version: "1.1.0"
lottie:
dependency: "direct main"
description:
path: ".."
relative: true
source: path
version: "1.4.0"
version: "2.0.0"
matcher:
dependency: transitive
description:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.11"
version: "0.12.12"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.4"
version: "0.1.5"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.0"
version: "1.8.0"
path:
dependency: "direct main"
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.1"
version: "1.8.2"
path_provider:
dependency: "direct main"
description:
@ -185,14 +178,14 @@ packages:
name: path_provider_android
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.16"
version: "2.0.21"
path_provider_ios:
dependency: transitive
description:
name: path_provider_ios
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.10"
version: "2.0.11"
path_provider_linux:
dependency: transitive
description:
@ -213,14 +206,14 @@ packages:
name: path_provider_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.4"
version: "2.0.5"
path_provider_windows:
dependency: transitive
description:
name: path_provider_windows
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
version: "2.1.3"
platform:
dependency: transitive
description:
@ -234,7 +227,7 @@ packages:
name: plugin_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.2"
version: "2.1.3"
process:
dependency: transitive
description:
@ -253,7 +246,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.2"
version: "1.9.0"
stack_trace:
dependency: transitive
description:
@ -274,21 +267,21 @@ packages:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.1.1"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.2.1"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.9"
version: "0.4.12"
typed_data:
dependency: transitive
description:
@ -309,14 +302,14 @@ packages:
name: win32
url: "https://pub.dartlang.org"
source: hosted
version: "2.7.0"
version: "3.1.1"
xdg_directories:
dependency: transitive
description:
name: xdg_directories
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.0+1"
version: "0.2.0+2"
sdks:
dart: ">=2.17.0 <3.0.0"
flutter: ">=3.0.0"
dart: ">=2.18.0 <3.0.0"
flutter: ">=3.3.0"

View File

@ -3,7 +3,7 @@ description: A sample app for the Lottie player
publish_to: none
environment:
sdk: ">=2.12.0-0 <3.0.0"
sdk: ">=2.18.0 <3.0.0"
dependencies:
flutter:

View File

@ -4,7 +4,7 @@ import '../../value/keyframe.dart';
import 'keyframe_animation.dart';
class ColorKeyframeAnimation extends KeyframeAnimation<Color> {
ColorKeyframeAnimation(List<Keyframe<Color>> keyframes) : super(keyframes);
ColorKeyframeAnimation(super.keyframes);
@override
Color getValue(Keyframe<Color> keyframe, double keyframeProgress) {

View File

@ -3,7 +3,7 @@ import '../../value/keyframe.dart';
import 'keyframe_animation.dart';
class DoubleKeyframeAnimation extends KeyframeAnimation<double> {
DoubleKeyframeAnimation(List<Keyframe<double>> keyframes) : super(keyframes);
DoubleKeyframeAnimation(super.keyframes);
@override
double getValue(Keyframe<double> keyframe, double keyframeProgress) {

View File

@ -3,7 +3,7 @@ import '../../value/keyframe.dart';
import 'keyframe_animation.dart';
class IntegerKeyframeAnimation extends KeyframeAnimation<int> {
IntegerKeyframeAnimation(List<Keyframe<int>> keyframes) : super(keyframes);
IntegerKeyframeAnimation(super.keyframes);
@override
int getValue(Keyframe<int> keyframe, double keyframeProgress) {

View File

@ -1,7 +1,6 @@
import '../../value/keyframe.dart';
import 'base_keyframe_animation.dart';
abstract class KeyframeAnimation<T extends Object>
extends BaseKeyframeAnimation<T, T> {
KeyframeAnimation(List<Keyframe<T>> keyframes) : super(keyframes);
KeyframeAnimation(super.keyframes);
}

View File

@ -7,9 +7,9 @@ class PathKeyframe extends Keyframe<Offset> {
Path? _path;
final Keyframe<Offset> _pointKeyFrame;
PathKeyframe(LottieComposition composition, Keyframe<Offset> keyframe)
PathKeyframe(LottieComposition super.composition, Keyframe<Offset> keyframe)
: _pointKeyFrame = keyframe,
super(composition,
super(
startValue: keyframe.startValue,
endValue: keyframe.endValue,
interpolator: keyframe.interpolator,

View File

@ -7,7 +7,7 @@ class PathKeyframeAnimation extends KeyframeAnimation<Offset> {
PathKeyframe? _pathMeasureKeyframe;
late PathMetric _pathMeasure;
PathKeyframeAnimation(List<Keyframe<Offset>> keyframes) : super(keyframes);
PathKeyframeAnimation(super.keyframes);
@override
Offset getValue(Keyframe<Offset> keyframe, double keyframeProgress) {

View File

@ -3,7 +3,7 @@ import '../../value/keyframe.dart';
import 'keyframe_animation.dart';
class PointKeyframeAnimation extends KeyframeAnimation<Offset> {
PointKeyframeAnimation(List<Keyframe<Offset>> keyframes) : super(keyframes);
PointKeyframeAnimation(super.keyframes);
@override
Offset getValue(Keyframe<Offset> keyframe, double keyframeProgress) {

View File

@ -11,8 +11,7 @@ class ShapeKeyframeAnimation extends BaseKeyframeAnimation<ShapeData, Path> {
final Path _tempPath = PathFactory.create();
List<ShapeModifierContent>? _shapeModifiers;
ShapeKeyframeAnimation(List<Keyframe<ShapeData>> keyframes)
: super(keyframes);
ShapeKeyframeAnimation(super.keyframes);
@override
Path getValue(Keyframe<ShapeData> keyframe, double keyframeProgress) {

View File

@ -5,8 +5,7 @@ import '../../value/lottie_value_callback.dart';
import 'keyframe_animation.dart';
class TextKeyframeAnimation extends KeyframeAnimation<DocumentData> {
TextKeyframeAnimation(List<Keyframe<DocumentData>> keyframes)
: super(keyframes);
TextKeyframeAnimation(super.keyframes);
@override
DocumentData getValue(

View File

@ -12,7 +12,7 @@ import 'lottie_builder.dart';
/// [repeat] and [reverse].
class Lottie extends StatefulWidget {
const Lottie({
Key? key,
super.key,
required this.composition,
this.controller,
this.width,
@ -30,8 +30,7 @@ class Lottie extends StatefulWidget {
}) : animate = animate ?? true,
reverse = reverse ?? false,
repeat = repeat ?? true,
addRepaintBoundary = addRepaintBoundary ?? true,
super(key: key);
addRepaintBoundary = addRepaintBoundary ?? true;
/// Creates a widget that displays an [LottieComposition] obtained from an [AssetBundle].
static LottieBuilder asset(
@ -311,7 +310,7 @@ class Lottie extends StatefulWidget {
/// The quality of the image layer. See [FilterQuality]
/// [FilterQuality.high] is highest quality but slowest.
///
/// Defaults to [FilterQuality.none]
/// Defaults to [FilterQuality.low]
final FilterQuality? filterQuality;
static bool get traceEnabled => L.traceEnabled;

View File

@ -1,5 +1,4 @@
import 'dart:async';
import 'dart:typed_data';
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'composition.dart';
@ -33,16 +32,16 @@ typedef LottieErrorWidgetBuilder = Widget Function(
/// Several constructors are provided for the various ways that a Lottie file
/// can be provided:
///
/// * [new Lottie], for obtaining a composition from a [LottieProvider].
/// * [new Lottie.asset], for obtaining a Lottie file from an [AssetBundle]
/// * [Lottie], for obtaining a composition from a [LottieProvider].
/// * [Lottie.asset], for obtaining a Lottie file from an [AssetBundle]
/// using a key.
/// * [new Lottie.network], for obtaining a lottie file from a URL.
/// * [new Lottie.file], for obtaining a lottie file from a [File].
/// * [new Lottie.memory], for obtaining a lottie file from a [Uint8List].
/// * [Lottie.network], for obtaining a lottie file from a URL.
/// * [Lottie.file], for obtaining a lottie file from a [File].
/// * [Lottie.memory], for obtaining a lottie file from a [Uint8List].
///
class LottieBuilder extends StatefulWidget {
const LottieBuilder({
Key? key,
super.key,
required this.lottie,
this.controller,
this.frameRate,
@ -61,7 +60,7 @@ class LottieBuilder extends StatefulWidget {
this.addRepaintBoundary,
this.filterQuality,
this.onWarning,
}) : super(key: key);
});
/// Creates a widget that displays an [LottieComposition] obtained from the network.
LottieBuilder.network(
@ -76,7 +75,7 @@ class LottieBuilder extends StatefulWidget {
this.options,
LottieImageProviderFactory? imageProviderFactory,
this.onLoaded,
Key? key,
super.key,
this.frameBuilder,
this.errorBuilder,
this.width,
@ -87,8 +86,7 @@ class LottieBuilder extends StatefulWidget {
this.filterQuality,
this.onWarning,
}) : lottie = NetworkLottie(src,
headers: headers, imageProviderFactory: imageProviderFactory),
super(key: key);
headers: headers, imageProviderFactory: imageProviderFactory);
/// Creates a widget that displays an [LottieComposition] obtained from a [File].
///
@ -111,7 +109,7 @@ class LottieBuilder extends StatefulWidget {
this.options,
LottieImageProviderFactory? imageProviderFactory,
this.onLoaded,
Key? key,
super.key,
this.frameBuilder,
this.errorBuilder,
this.width,
@ -121,8 +119,7 @@ class LottieBuilder extends StatefulWidget {
this.addRepaintBoundary,
this.filterQuality,
this.onWarning,
}) : lottie = FileLottie(file, imageProviderFactory: imageProviderFactory),
super(key: key);
}) : lottie = FileLottie(file, imageProviderFactory: imageProviderFactory);
/// Creates a widget that displays an [LottieComposition] obtained from an [AssetBundle].
LottieBuilder.asset(
@ -136,7 +133,7 @@ class LottieBuilder extends StatefulWidget {
this.options,
LottieImageProviderFactory? imageProviderFactory,
this.onLoaded,
Key? key,
super.key,
AssetBundle? bundle,
this.frameBuilder,
this.errorBuilder,
@ -151,8 +148,7 @@ class LottieBuilder extends StatefulWidget {
}) : lottie = AssetLottie(name,
bundle: bundle,
package: package,
imageProviderFactory: imageProviderFactory),
super(key: key);
imageProviderFactory: imageProviderFactory);
/// Creates a widget that displays an [LottieComposition] obtained from a [Uint8List].
LottieBuilder.memory(
@ -167,7 +163,7 @@ class LottieBuilder extends StatefulWidget {
LottieImageProviderFactory? imageProviderFactory,
this.onLoaded,
this.errorBuilder,
Key? key,
super.key,
this.frameBuilder,
this.width,
this.height,
@ -176,9 +172,7 @@ class LottieBuilder extends StatefulWidget {
this.addRepaintBoundary,
this.filterQuality,
this.onWarning,
}) : lottie =
MemoryLottie(bytes, imageProviderFactory: imageProviderFactory),
super(key: key);
}) : lottie = MemoryLottie(bytes, imageProviderFactory: imageProviderFactory);
/// The lottie animation to load.
/// Example of providers: [AssetLottie], [NetworkLottie], [FileLottie], [MemoryLottie]
@ -369,7 +363,7 @@ class LottieBuilder extends StatefulWidget {
/// The quality of the image layer. See [FilterQuality]
/// [FilterQuality.high] is highest quality but slowest.
///
/// Defaults to [FilterQuality.none]
/// Defaults to [FilterQuality.low]
final FilterQuality? filterQuality;
/// A callback called when there is a warning during the loading or painting

View File

@ -82,5 +82,5 @@ class LottieDelegates {
values == other.values;
@override
int get hashCode => hashValues(text, textStyle, values);
int get hashCode => Object.hash(text, textStyle, values);
}

View File

@ -1,11 +1,9 @@
import 'dart:ui';
import '../../animation/keyframe/color_keyframe_animation.dart';
import '../../value/keyframe.dart';
import 'base_animatable_value.dart';
class AnimatableColorValue extends BaseAnimatableValue<Color, Color> {
AnimatableColorValue.fromKeyframes(List<Keyframe<Color>> keyframes)
: super.fromKeyframes(keyframes);
AnimatableColorValue.fromKeyframes(super.keyframes) : super.fromKeyframes();
@override
ColorKeyframeAnimation createAnimation() {

View File

@ -1,12 +1,10 @@
import '../../animation/keyframe/double_keyframe_animation.dart';
import '../../value/keyframe.dart';
import 'base_animatable_value.dart';
class AnimatableDoubleValue extends BaseAnimatableValue<double, double> {
AnimatableDoubleValue() : super.fromValue(0.0);
AnimatableDoubleValue.fromKeyframes(List<Keyframe<double>> keyframes)
: super.fromKeyframes(keyframes);
AnimatableDoubleValue.fromKeyframes(super.keyframes) : super.fromKeyframes();
@override
DoubleKeyframeAnimation createAnimation() {

View File

@ -1,13 +1,11 @@
import '../../animation/keyframe/gradient_color_keyframe_animation.dart';
import '../../value/keyframe.dart';
import '../content/gradient_color.dart';
import 'base_animatable_value.dart';
class AnimatableGradientColorValue
extends BaseAnimatableValue<GradientColor, GradientColor> {
AnimatableGradientColorValue.fromKeyframes(
List<Keyframe<GradientColor>> keyframes)
: super.fromKeyframes(keyframes);
AnimatableGradientColorValue.fromKeyframes(super.keyframes)
: super.fromKeyframes();
@override
GradientColorKeyframeAnimation createAnimation() {

View File

@ -1,13 +1,11 @@
import '../../animation/keyframe/base_keyframe_animation.dart';
import '../../animation/keyframe/integer_keyframe_animation.dart';
import '../../value/keyframe.dart';
import 'base_animatable_value.dart';
class AnimatableIntegerValue extends BaseAnimatableValue<int, int> {
AnimatableIntegerValue() : super.fromValue(100);
AnimatableIntegerValue.fromKeyframes(List<Keyframe<int>> keyframes)
: super.fromKeyframes(keyframes);
AnimatableIntegerValue.fromKeyframes(super.keyframes) : super.fromKeyframes();
@override
BaseKeyframeAnimation<int, int> createAnimation() {

View File

@ -1,11 +1,9 @@
import 'dart:ui';
import '../../animation/keyframe/point_keyframe_animation.dart';
import '../../value/keyframe.dart';
import 'base_animatable_value.dart';
class AnimatablePointValue extends BaseAnimatableValue<Offset, Offset> {
AnimatablePointValue.fromKeyframes(List<Keyframe<Offset>> keyframes)
: super.fromKeyframes(keyframes);
AnimatablePointValue.fromKeyframes(super.keyframes) : super.fromKeyframes();
@override
PointKeyframeAnimation createAnimation() {

View File

@ -1,16 +1,14 @@
import 'dart:ui';
import '../../animation/keyframe/base_keyframe_animation.dart';
import '../../animation/keyframe/point_keyframe_animation.dart';
import '../../value/keyframe.dart';
import 'base_animatable_value.dart';
class AnimatableScaleValue extends BaseAnimatableValue<Offset, Offset> {
AnimatableScaleValue.one() : this(const Offset(1, 1));
AnimatableScaleValue(Offset value) : super.fromValue(value);
AnimatableScaleValue(super.value) : super.fromValue();
AnimatableScaleValue.fromKeyframes(List<Keyframe<Offset>> keyframes)
: super.fromKeyframes(keyframes);
AnimatableScaleValue.fromKeyframes(super.keyframes) : super.fromKeyframes();
@override
BaseKeyframeAnimation<Offset, Offset> createAnimation() {

View File

@ -1,12 +1,10 @@
import 'dart:ui';
import '../../animation/keyframe/shape_keyframe_animation.dart';
import '../../value/keyframe.dart';
import '../content/shape_data.dart';
import 'base_animatable_value.dart';
class AnimatableShapeValue extends BaseAnimatableValue<ShapeData, Path> {
AnimatableShapeValue.fromKeyframes(List<Keyframe<ShapeData>> keyframes)
: super.fromKeyframes(keyframes);
AnimatableShapeValue.fromKeyframes(super.keyframes) : super.fromKeyframes();
@override
ShapeKeyframeAnimation createAnimation() {

View File

@ -1,12 +1,10 @@
import '../../animation/keyframe/text_keyframe_animation.dart';
import '../../value/keyframe.dart';
import '../document_data.dart';
import 'base_animatable_value.dart';
class AnimatableTextFrame
extends BaseAnimatableValue<DocumentData, DocumentData> {
AnimatableTextFrame.fromKeyframes(List<Keyframe<DocumentData>> keyframes)
: super.fromKeyframes(keyframes);
AnimatableTextFrame.fromKeyframes(super.keyframes) : super.fromKeyframes();
@override
TextKeyframeAnimation createAnimation() {

View File

@ -31,7 +31,7 @@ class DocumentData {
@override
int get hashCode {
return hashValues(
return Object.hash(
text,
fontName,
size,

View File

@ -2,19 +2,16 @@ import 'dart:ui';
import 'package:vector_math/vector_math_64.dart';
import '../../animation/keyframe/base_keyframe_animation.dart';
import '../../animation/keyframe/value_callback_keyframe_animation.dart';
import '../../lottie_drawable.dart';
import '../../lottie_property.dart';
import '../../utils.dart';
import '../../value/lottie_value_callback.dart';
import 'base_layer.dart';
import 'layer.dart';
class ImageLayer extends BaseLayer {
final Paint paint = Paint();
BaseKeyframeAnimation<ColorFilter, ColorFilter?>? _colorFilterAnimation;
ImageLayer(LottieDrawable lottieDrawable, Layer layerModel)
: super(lottieDrawable, layerModel);
ImageLayer(super.lottieDrawable, super.layerModel);
@override
void drawLayer(Canvas canvas, Size size, Matrix4 parentMatrix,
@ -23,9 +20,8 @@ class ImageLayer extends BaseLayer {
if (bitmap == null) {
return;
}
var density = window.devicePixelRatio;
paint.filterQuality = lottieDrawable.filterQuality ?? FilterQuality.none;
paint.filterQuality = lottieDrawable.filterQuality ?? FilterQuality.low;
paint.setAlpha(parentAlpha);
if (_colorFilterAnimation != null) {
paint.colorFilter = _colorFilterAnimation!.value;
@ -34,8 +30,8 @@ class ImageLayer extends BaseLayer {
canvas.transform(parentMatrix.storage);
var src =
Rect.fromLTWH(0, 0, bitmap.width.toDouble(), bitmap.height.toDouble());
var dst = Rect.fromLTWH(
0, 0, bitmap.width * density, bitmap.height.toDouble() * density);
var dst =
Rect.fromLTWH(0, 0, bitmap.width.toDouble(), bitmap.height.toDouble());
canvas.drawImageRect(bitmap, src, dst, paint);
canvas.restore();
}
@ -45,8 +41,8 @@ class ImageLayer extends BaseLayer {
var superBounds = super.getBounds(parentMatrix, applyParents: applyParents);
var bitmap = getBitmap();
if (bitmap != null) {
var bounds = Rect.fromLTWH(0, 0, bitmap.width * window.devicePixelRatio,
bitmap.height * window.devicePixelRatio);
var bounds = Rect.fromLTWH(
0, 0, bitmap.width.toDouble(), bitmap.height.toDouble());
return boundsMatrix.mapRect(bounds);
}
return superBounds;

View File

@ -1,12 +1,9 @@
import 'dart:ui';
import 'package:vector_math/vector_math_64.dart';
import '../../lottie_drawable.dart';
import 'base_layer.dart';
import 'layer.dart';
class NullLayer extends BaseLayer {
NullLayer(LottieDrawable lottieDrawable, Layer layerModel)
: super(lottieDrawable, layerModel);
NullLayer(super.lottieDrawable, super.layerModel);
@override
void drawLayer(Canvas canvas, Size size, Matrix4 parentMatrix,

View File

@ -1,4 +1,3 @@
import 'dart:ui';
import 'package:flutter/widgets.dart';
import '../../animation/content/content_group.dart';
import '../../animation/keyframe/base_keyframe_animation.dart';
@ -132,8 +131,7 @@ class TextLayer extends BaseLayer {
_strokePaint.strokeWidth = _strokeWidthAnimation!.value;
} else {
var parentScale = parentMatrix.getScale();
_strokePaint.strokeWidth =
documentData.strokeWidth * window.devicePixelRatio * parentScale;
_strokePaint.strokeWidth = documentData.strokeWidth * parentScale;
}
if (lottieDrawable.useTextGlyphs) {
@ -159,9 +157,10 @@ class TextLayer extends BaseLayer {
var parentScale = parentMatrix.getScale();
var text = documentData.text;
canvas.transform(parentMatrix.storage);
// Line height
var lineHeight = documentData.lineHeight * window.devicePixelRatio;
var lineHeight = documentData.lineHeight;
// Split full text in multiple lines
var textLines = _getTextLines(text);
@ -182,12 +181,14 @@ class TextLayer extends BaseLayer {
canvas.translate(0, translateY);
// Draw each line
_drawGlyphTextLine(textLine, documentData, parentMatrix, font, canvas,
_drawGlyphTextLine(textLine, documentData, Matrix4.identity(), font, canvas,
parentScale, fontScale);
// Reset canvas
canvas.restore();
}
canvas.restore();
}
void _drawGlyphTextLine(
@ -208,8 +209,7 @@ class TextLayer extends BaseLayer {
}
_drawCharacterAsGlyph(
character, parentMatrix, fontScale, documentData, canvas);
var tx =
character.width * fontScale * window.devicePixelRatio * parentScale;
var tx = character.width * fontScale * parentScale;
// Add tracking
var tracking = documentData.tracking / 10.0;
if (_trackingCallbackAnimation != null) {
@ -238,11 +238,10 @@ class TextLayer extends BaseLayer {
} else {
textSize = documentData.size;
}
textStyle =
textStyle.copyWith(fontSize: textSize * window.devicePixelRatio);
textStyle = textStyle.copyWith(fontSize: textSize);
// Line height
var lineHeight = documentData.lineHeight * window.devicePixelRatio;
var lineHeight = documentData.lineHeight;
// Calculate tracking
var tracking = documentData.tracking / 10;
@ -251,7 +250,7 @@ class TextLayer extends BaseLayer {
} else if (_trackingAnimation != null) {
tracking += _trackingAnimation!.value;
}
tracking = tracking * window.devicePixelRatio * textSize / 100.0;
tracking = tracking * textSize / 100.0;
// Split full text in multiple lines
var textLines = _getTextLines(text);
@ -316,8 +315,7 @@ class TextLayer extends BaseLayer {
if (character == null) {
continue;
}
textLineWidth +=
character.width * fontScale * window.devicePixelRatio * parentScale;
textLineWidth += character.width * fontScale * parentScale;
}
return textLineWidth;
}
@ -344,8 +342,7 @@ class TextLayer extends BaseLayer {
var path = contentGroups[j].getPath();
path.getBounds();
_matrix.set(parentMatrix);
_matrix.translate(
0.0, -documentData.baselineShift * window.devicePixelRatio);
_matrix.translate(0.0, -documentData.baselineShift);
_matrix.scale(fontScale, fontScale);
path = path.transform(_matrix.storage);
if (documentData.strokeOverFill) {

View File

@ -27,8 +27,8 @@ class AnimatablePathValueParser {
reader.endArray();
KeyframesParser.setEndFrames(keyframes);
} else {
keyframes.add(Keyframe<Offset>.nonAnimated(
JsonUtils.jsonToPoint(reader, window.devicePixelRatio)));
keyframes
.add(Keyframe<Offset>.nonAnimated(JsonUtils.jsonToPoint(reader)));
}
return AnimatablePathValue.fromKeyframes(keyframes);
}

View File

@ -74,8 +74,7 @@ class AnimatableTransformParser {
// ]
// },
// which doesn't parse to a real keyframe.
rotation = AnimatableValueParser.parseFloat(reader, composition,
isDp: false);
rotation = AnimatableValueParser.parseFloat(reader, composition);
if (rotation.keyframes.isEmpty) {
rotation.keyframes.add(Keyframe(composition,
startValue: 0.0,
@ -96,20 +95,16 @@ class AnimatableTransformParser {
opacity = AnimatableValueParser.parseInteger(reader, composition);
break;
case 6:
startOpacity = AnimatableValueParser.parseFloat(reader, composition,
isDp: false);
startOpacity = AnimatableValueParser.parseFloat(reader, composition);
break;
case 7:
endOpacity = AnimatableValueParser.parseFloat(reader, composition,
isDp: false);
endOpacity = AnimatableValueParser.parseFloat(reader, composition);
break;
case 8:
skew = AnimatableValueParser.parseFloat(reader, composition,
isDp: false);
skew = AnimatableValueParser.parseFloat(reader, composition);
break;
case 9:
skewAngle = AnimatableValueParser.parseFloat(reader, composition,
isDp: false);
skewAngle = AnimatableValueParser.parseFloat(reader, composition);
break;
default:
reader.skipName();

View File

@ -1,4 +1,3 @@
import 'dart:ui';
import '../composition.dart';
import '../model/animatable/animatable_color_value.dart';
import '../model/animatable/animatable_double_value.dart';
@ -25,12 +24,9 @@ class AnimatableValueParser {
AnimatableValueParser._();
static AnimatableDoubleValue parseFloat(
JsonReader reader, LottieComposition composition,
{bool? isDp}) {
isDp ??= true;
return AnimatableDoubleValue.fromKeyframes(parse(
reader, composition, floatParser,
scale: isDp ? window.devicePixelRatio : 1.0));
JsonReader reader, LottieComposition composition) {
return AnimatableDoubleValue.fromKeyframes(
parse(reader, composition, floatParser));
}
static AnimatableIntegerValue parseInteger(
@ -42,7 +38,7 @@ class AnimatableValueParser {
static AnimatablePointValue parsePoint(
JsonReader reader, LottieComposition composition) {
return AnimatablePointValue.fromKeyframes(KeyframesParser.parse(
reader, composition, window.devicePixelRatio, offsetParser,
reader, composition, offsetParser,
multiDimensional: true));
}
@ -54,9 +50,8 @@ class AnimatableValueParser {
static AnimatableShapeValue parseShapeData(
JsonReader reader, LottieComposition composition) {
return AnimatableShapeValue.fromKeyframes(parse(
reader, composition, shapeDataParser,
scale: window.devicePixelRatio));
return AnimatableShapeValue.fromKeyframes(
parse(reader, composition, shapeDataParser));
}
static AnimatableTextFrame parseDocumentData(
@ -81,6 +76,6 @@ class AnimatableValueParser {
LottieComposition composition, ValueParser<T> valueParser,
{double? scale}) {
scale ??= 1.0;
return KeyframesParser.parse(reader, composition, scale, valueParser);
return KeyframesParser.parse(reader, composition, valueParser);
}
}

View File

@ -1,7 +1,7 @@
import 'dart:ui';
import 'moshi/json_reader.dart';
Color colorParser(JsonReader reader, {required double scale}) {
Color colorParser(JsonReader reader) {
var isArray = reader.peek() == Token.beginArray;
if (isArray) {
reader.beginArray();

View File

@ -17,7 +17,7 @@ final JsonReaderOptions _names = JsonReaderOptions.of([
'of', // 10
]);
DocumentData documentDataParser(JsonReader reader, {required double scale}) {
DocumentData documentDataParser(JsonReader reader) {
String? text;
String? fontName;
var size = 0.0;

View File

@ -69,12 +69,11 @@ class DropShadowEffectParser {
_color = AnimatableValueParser.parseColor(reader, composition);
break;
case 'Opacity':
_opacity = AnimatableValueParser.parseFloat(reader, composition,
isDp: false);
_opacity = AnimatableValueParser.parseFloat(reader, composition);
break;
case 'Direction':
_direction = AnimatableValueParser.parseFloat(reader, composition,
isDp: false);
_direction =
AnimatableValueParser.parseFloat(reader, composition);
break;
case 'Distance':
_distance = AnimatableValueParser.parseFloat(reader, composition);

View File

@ -1,6 +1,6 @@
import 'json_utils.dart';
import 'moshi/json_reader.dart';
double floatParser(JsonReader reader, {required double scale}) {
return JsonUtils.valueFromObject(reader) * scale;
double floatParser(JsonReader reader) {
return JsonUtils.valueFromObject(reader);
}

View File

@ -26,7 +26,7 @@ class GradientColorParser {
/// opacity,
/// ...
/// ]
GradientColor parse(JsonReader reader, {required double scale}) {
GradientColor parse(JsonReader reader) {
var array = <double>[];
// The array was started by Keyframe because it thought that this may be an array of keyframes
// but peek returned a number so it considered it a static array of numbers.

View File

@ -1,6 +1,6 @@
import 'json_utils.dart';
import 'moshi/json_reader.dart';
int integerParser(JsonReader reader, {required double scale}) {
return (JsonUtils.valueFromObject(reader) * scale).round();
int integerParser(JsonReader reader) {
return JsonUtils.valueFromObject(reader).round();
}

View File

@ -14,43 +14,43 @@ class JsonUtils {
return Color.fromARGB(255, r, g, b);
}
static List<Offset> jsonToPoints(JsonReader reader, double scale) {
static List<Offset> jsonToPoints(JsonReader reader) {
var points = <Offset>[];
reader.beginArray();
while (reader.peek() == Token.beginArray) {
reader.beginArray();
points.add(jsonToPoint(reader, scale));
points.add(jsonToPoint(reader));
reader.endArray();
}
reader.endArray();
return points;
}
static Offset jsonToPoint(JsonReader reader, double scale) {
static Offset jsonToPoint(JsonReader reader) {
switch (reader.peek()) {
case Token.number:
return _jsonNumbersToPoint(reader, scale);
return _jsonNumbersToPoint(reader);
case Token.beginArray:
return _jsonArrayToPoint(reader, scale);
return _jsonArrayToPoint(reader);
case Token.beginObject:
return _jsonObjectToPoint(reader, scale: scale);
return _jsonObjectToPoint(reader);
// ignore: no_default_cases
default:
throw Exception('Unknown point starts with ${reader.peek()}');
}
}
static Offset _jsonNumbersToPoint(JsonReader reader, double scale) {
static Offset _jsonNumbersToPoint(JsonReader reader) {
var x = reader.nextDouble();
var y = reader.nextDouble();
while (reader.hasNext()) {
reader.skipValue();
}
return Offset(x * scale, y * scale);
return Offset(x, y);
}
static Offset _jsonArrayToPoint(JsonReader reader, double scale) {
static Offset _jsonArrayToPoint(JsonReader reader) {
double x;
double y;
reader.beginArray();
@ -60,12 +60,12 @@ class JsonUtils {
reader.skipValue();
}
reader.endArray();
return Offset(x * scale, y * scale);
return Offset(x, y);
}
static final JsonReaderOptions _pointNames = JsonReaderOptions.of(['x', 'y']);
static Offset _jsonObjectToPoint(JsonReader reader, {required double scale}) {
static Offset _jsonObjectToPoint(JsonReader reader) {
var x = 0.0;
var y = 0.0;
reader.beginObject();
@ -83,7 +83,7 @@ class JsonUtils {
}
}
reader.endObject();
return Offset(x * scale, y * scale);
return Offset(x, y);
}
static double valueFromObject(JsonReader reader) {

View File

@ -26,22 +26,21 @@ class KeyframeParser {
/// @param multiDimensional When true, the keyframe interpolators can be independent for the X and Y axis.
static Keyframe<T> parse<T>(JsonReader reader, LottieComposition composition,
double scale, ValueParser<T> valueParser,
ValueParser<T> valueParser,
{required bool animated, bool multiDimensional = false}) {
if (animated && multiDimensional) {
return _parseMultiDimensionalKeyframe(
composition, reader, scale, valueParser);
return _parseMultiDimensionalKeyframe(composition, reader, valueParser);
} else if (animated) {
return _parseKeyframe(composition, reader, scale, valueParser);
return _parseKeyframe(composition, reader, valueParser);
} else {
return _parseStaticValue(reader, scale, valueParser);
return _parseStaticValue(reader, valueParser);
}
}
/// beginObject will already be called on the keyframe so it can be differentiated with
/// a non animated value.
static Keyframe<T> _parseKeyframe<T>(LottieComposition composition,
JsonReader reader, double scale, ValueParser<T> valueParser) {
JsonReader reader, ValueParser<T> valueParser) {
Offset? cp1;
Offset? cp2;
var startFrame = 0.0;
@ -61,25 +60,25 @@ class KeyframeParser {
startFrame = reader.nextDouble();
break;
case 1:
startValue = valueParser(reader, scale: scale);
startValue = valueParser(reader);
break;
case 2:
endValue = valueParser(reader, scale: scale);
endValue = valueParser(reader);
break;
case 3:
cp1 = JsonUtils.jsonToPoint(reader, 1);
cp1 = JsonUtils.jsonToPoint(reader);
break;
case 4:
cp2 = JsonUtils.jsonToPoint(reader, 1);
cp2 = JsonUtils.jsonToPoint(reader);
break;
case 5:
hold = reader.nextInt() == 1;
break;
case 6:
pathCp1 = JsonUtils.jsonToPoint(reader, scale);
pathCp1 = JsonUtils.jsonToPoint(reader);
break;
case 7:
pathCp2 = JsonUtils.jsonToPoint(reader, scale);
pathCp2 = JsonUtils.jsonToPoint(reader);
break;
default:
reader.skipValue();
@ -111,7 +110,6 @@ class KeyframeParser {
static Keyframe<T> _parseMultiDimensionalKeyframe<T>(
LottieComposition composition,
JsonReader reader,
double scale,
ValueParser<T> valueParser) {
Offset? cp1;
Offset? cp2;
@ -140,10 +138,10 @@ class KeyframeParser {
startFrame = reader.nextDouble();
break;
case 1: // s
startValue = valueParser(reader, scale: scale);
startValue = valueParser(reader);
break;
case 2: // e
endValue = valueParser(reader, scale: scale);
endValue = valueParser(reader);
break;
case 3: // o
if (reader.peek() == Token.beginObject) {
@ -192,7 +190,7 @@ class KeyframeParser {
yCp1 = Offset(yCp1x, yCp1y);
reader.endObject();
} else {
cp1 = JsonUtils.jsonToPoint(reader, scale);
cp1 = JsonUtils.jsonToPoint(reader);
}
break;
case 4: // i
@ -242,17 +240,17 @@ class KeyframeParser {
yCp2 = Offset(yCp2x, yCp2y);
reader.endObject();
} else {
cp2 = JsonUtils.jsonToPoint(reader, scale);
cp2 = JsonUtils.jsonToPoint(reader);
}
break;
case 5: // h
hold = reader.nextInt() == 1;
break;
case 6: // to
pathCp1 = JsonUtils.jsonToPoint(reader, scale);
pathCp1 = JsonUtils.jsonToPoint(reader);
break;
case 7: // ti
pathCp2 = JsonUtils.jsonToPoint(reader, scale);
pathCp2 = JsonUtils.jsonToPoint(reader);
break;
default:
reader.skipValue();
@ -322,8 +320,8 @@ class KeyframeParser {
}
static Keyframe<T> _parseStaticValue<T>(
JsonReader reader, double scale, ValueParser<T> valueParser) {
var value = valueParser(reader, scale: scale);
JsonReader reader, ValueParser<T> valueParser) {
var value = valueParser(reader);
return Keyframe<T>.nonAnimated(value);
}
}

View File

@ -11,7 +11,7 @@ class KeyframesParser {
KeyframesParser._();
static List<Keyframe<T>> parse<T>(JsonReader reader,
LottieComposition composition, double scale, ValueParser<T> valueParser,
LottieComposition composition, ValueParser<T> valueParser,
{bool multiDimensional = false}) {
var keyframes = <Keyframe<T>>[];
@ -30,19 +30,18 @@ class KeyframesParser {
if (reader.peek() == Token.number) {
// For properties in which the static value is an array of numbers.
keyframes.add(KeyframeParser.parse(
reader, composition, scale, valueParser,
reader, composition, valueParser,
animated: false, multiDimensional: multiDimensional));
} else {
while (reader.hasNext()) {
keyframes.add(KeyframeParser.parse(
reader, composition, scale, valueParser,
reader, composition, valueParser,
animated: true, multiDimensional: multiDimensional));
}
}
reader.endArray();
} else {
keyframes.add(KeyframeParser.parse(
reader, composition, scale, valueParser,
keyframes.add(KeyframeParser.parse(reader, composition, valueParser,
animated: false, multiDimensional: multiDimensional));
}
break;

View File

@ -136,10 +136,10 @@ class LayerParser {
parentId = reader.nextInt();
break;
case 5:
solidWidth = (reader.nextInt() * window.devicePixelRatio).round();
solidWidth = reader.nextInt();
break;
case 6:
solidHeight = (reader.nextInt() * window.devicePixelRatio).round();
solidHeight = reader.nextInt();
break;
case 7:
solidColor = MiscUtils.parseColor(reader.nextString(),
@ -246,10 +246,10 @@ class LayerParser {
startFrame = reader.nextDouble();
break;
case 16:
preCompWidth = (reader.nextInt() * window.devicePixelRatio).round();
preCompWidth = reader.nextInt();
break;
case 17:
preCompHeight = (reader.nextInt() * window.devicePixelRatio).round();
preCompHeight = reader.nextInt();
break;
case 18:
inFrame = reader.nextDouble();
@ -258,8 +258,7 @@ class LayerParser {
outFrame = reader.nextDouble();
break;
case 20:
timeRemapping = AnimatableValueParser.parseFloat(reader, composition,
isDp: false);
timeRemapping = AnimatableValueParser.parseFloat(reader, composition);
break;
case 21:
cl = reader.nextString();

View File

@ -1,4 +1,3 @@
import 'dart:ui';
import '../composition.dart';
import '../lottie_image_asset.dart';
import '../model/font.dart';
@ -29,16 +28,15 @@ class LottieCompositionParser {
static LottieComposition parse(
LottieComposition composition, JsonReader reader) {
var parameters = CompositionParameters.forComposition(composition);
var scale = window.devicePixelRatio;
reader.beginObject();
while (reader.hasNext()) {
switch (reader.selectName(_names)) {
case 0:
parameters.bounds.width = (reader.nextInt() * scale).round();
parameters.bounds.width = (reader.nextInt()).round();
break;
case 1:
parameters.bounds.height = (reader.nextInt() * scale).round();
parameters.bounds.height = (reader.nextInt()).round();
break;
case 2:
parameters.startFrame = reader.nextDouble();

View File

@ -2,18 +2,17 @@ import 'dart:ui';
import 'json_utils.dart';
import 'moshi/json_reader.dart';
Offset offsetParser(JsonReader reader, {required double scale}) {
Offset offsetParser(JsonReader reader) {
var token = reader.peek();
if (token == Token.beginArray) {
return JsonUtils.jsonToPoint(reader, scale);
return JsonUtils.jsonToPoint(reader);
} else if (token == Token.beginObject) {
return JsonUtils.jsonToPoint(reader, scale);
return JsonUtils.jsonToPoint(reader);
} else if (token == Token.number) {
// This is the case where the static value for a property is an array of numbers.
// We begin the array to see if we have an array of keyframes but it's just an array
// of static numbers instead.
var point =
Offset(reader.nextDouble() * scale, reader.nextDouble() * scale);
var point = Offset(reader.nextDouble(), reader.nextDouble());
while (reader.hasNext()) {
reader.skipValue();
}

View File

@ -10,8 +10,7 @@ class PathKeyframeParser {
static PathKeyframe parse(JsonReader reader, LottieComposition composition) {
var animated = reader.peek() == Token.beginObject;
var keyframe = KeyframeParser.parse<Offset>(
reader, composition, window.devicePixelRatio, pathParser,
var keyframe = KeyframeParser.parse<Offset>(reader, composition, pathParser,
animated: animated);
return PathKeyframe(composition, keyframe);

View File

@ -2,6 +2,6 @@ import 'dart:ui';
import 'json_utils.dart';
import 'moshi/json_reader.dart';
Offset pathParser(JsonReader reader, {required double scale}) {
return JsonUtils.jsonToPoint(reader, scale);
Offset pathParser(JsonReader reader) {
return JsonUtils.jsonToPoint(reader);
}

View File

@ -36,32 +36,28 @@ class PolystarShapeParser {
type = PolystarShapeType.forValue(reader.nextInt());
break;
case 2:
points = AnimatableValueParser.parseFloat(reader, composition,
isDp: false);
points = AnimatableValueParser.parseFloat(reader, composition);
break;
case 3:
position =
AnimatablePathValueParser.parseSplitPath(reader, composition);
break;
case 4:
rotation = AnimatableValueParser.parseFloat(reader, composition,
isDp: false);
rotation = AnimatableValueParser.parseFloat(reader, composition);
break;
case 5:
outerRadius = AnimatableValueParser.parseFloat(reader, composition);
break;
case 6:
outerRoundedness = AnimatableValueParser.parseFloat(
reader, composition,
isDp: false);
outerRoundedness =
AnimatableValueParser.parseFloat(reader, composition);
break;
case 7:
innerRadius = AnimatableValueParser.parseFloat(reader, composition);
break;
case 8:
innerRoundedness = AnimatableValueParser.parseFloat(
reader, composition,
isDp: false);
innerRoundedness =
AnimatableValueParser.parseFloat(reader, composition);
break;
case 9:
hidden = reader.nextBoolean();

View File

@ -25,12 +25,10 @@ class RepeaterParser {
name = reader.nextString();
break;
case 1:
copies = AnimatableValueParser.parseFloat(reader, composition,
isDp: false);
copies = AnimatableValueParser.parseFloat(reader, composition);
break;
case 2:
offset = AnimatableValueParser.parseFloat(reader, composition,
isDp: false);
offset = AnimatableValueParser.parseFloat(reader, composition);
break;
case 3:
transform = AnimatableTransformParser.parse(reader, composition);

View File

@ -23,8 +23,7 @@ class RoundedCornersParser {
name = reader.nextString();
break;
case 1: // r
cornerRadius =
AnimatableValueParser.parseFloat(reader, composition, isDp: true);
cornerRadius = AnimatableValueParser.parseFloat(reader, composition);
break;
case 2: // hd
hidden = reader.nextBoolean();

View File

@ -1,7 +1,7 @@
import 'dart:ui';
import 'moshi/json_reader.dart';
Offset scaleXYParser(JsonReader reader, {required double scale}) {
Offset scaleXYParser(JsonReader reader) {
var isArray = reader.peek() == Token.beginArray;
if (isArray) {
reader.beginArray();
@ -14,5 +14,5 @@ Offset scaleXYParser(JsonReader reader, {required double scale}) {
if (isArray) {
reader.endArray();
}
return Offset(sx / 100.0 * scale, sy / 100.0 * scale);
return Offset(sx / 100.0, sy / 100.0);
}

View File

@ -6,7 +6,7 @@ import 'moshi/json_reader.dart';
final JsonReaderOptions _names = JsonReaderOptions.of(['c', 'v', 'i', 'o']);
ShapeData shapeDataParser(JsonReader reader, {required double scale}) {
ShapeData shapeDataParser(JsonReader reader) {
// Sometimes the points data is in a array of length 1. Sometimes the data is at the top
// level.
if (reader.peek() == Token.beginArray) {
@ -25,13 +25,13 @@ ShapeData shapeDataParser(JsonReader reader, {required double scale}) {
closed = reader.nextBoolean();
break;
case 1:
pointsArray = JsonUtils.jsonToPoints(reader, scale);
pointsArray = JsonUtils.jsonToPoints(reader);
break;
case 2:
inTangents = JsonUtils.jsonToPoints(reader, scale);
inTangents = JsonUtils.jsonToPoints(reader);
break;
case 3:
outTangents = JsonUtils.jsonToPoints(reader, scale);
outTangents = JsonUtils.jsonToPoints(reader);
break;
default:
reader.skipName();

View File

@ -19,16 +19,13 @@ class ShapeTrimPathParser {
while (reader.hasNext()) {
switch (reader.selectName(_names)) {
case 0:
start = AnimatableValueParser.parseFloat(reader, composition,
isDp: false);
start = AnimatableValueParser.parseFloat(reader, composition);
break;
case 1:
end = AnimatableValueParser.parseFloat(reader, composition,
isDp: false);
end = AnimatableValueParser.parseFloat(reader, composition);
break;
case 2:
offset = AnimatableValueParser.parseFloat(reader, composition,
isDp: false);
offset = AnimatableValueParser.parseFloat(reader, composition);
break;
case 3:
name = reader.nextString();

View File

@ -1,3 +1,3 @@
import 'moshi/json_reader.dart';
typedef ValueParser<V> = V Function(JsonReader reader, {required double scale});
typedef ValueParser<V> = V Function(JsonReader reader);

View File

@ -13,8 +13,8 @@ class AssetLottie extends LottieProvider {
this.assetName, {
this.bundle,
this.package,
LottieImageProviderFactory? imageProviderFactory,
}) : super(imageProviderFactory: imageProviderFactory);
super.imageProviderFactory,
});
final String assetName;
String get keyName =>
@ -67,7 +67,7 @@ class AssetLottie extends LottieProvider {
}
@override
int get hashCode => hashValues(keyName, bundle);
int get hashCode => Object.hash(keyName, bundle);
@override
String toString() => '$runtimeType(bundle: $bundle, name: "$keyName")';

View File

@ -7,8 +7,7 @@ import 'lottie_provider.dart';
import 'provider_io.dart' if (dart.library.html) 'provider_web.dart' as io;
class FileLottie extends LottieProvider {
FileLottie(this.file, {LottieImageProviderFactory? imageProviderFactory})
: super(imageProviderFactory: imageProviderFactory);
FileLottie(this.file, {super.imageProviderFactory});
final Object /*io.File|html.File*/ file;

View File

@ -8,8 +8,7 @@ import 'load_image.dart';
import 'lottie_provider.dart';
class MemoryLottie extends LottieProvider {
MemoryLottie(this.bytes, {LottieImageProviderFactory? imageProviderFactory})
: super(imageProviderFactory: imageProviderFactory);
MemoryLottie(this.bytes, {super.imageProviderFactory});
final Uint8List bytes;

View File

@ -9,9 +9,7 @@ import 'lottie_provider.dart';
import 'provider_io.dart' if (dart.library.html) 'provider_web.dart' as network;
class NetworkLottie extends LottieProvider {
NetworkLottie(this.url,
{this.headers, LottieImageProviderFactory? imageProviderFactory})
: super(imageProviderFactory: imageProviderFactory);
NetworkLottie(this.url, {this.headers, super.imageProviderFactory});
final String url;
final Map<String, String>? headers;

View File

@ -1,5 +1,4 @@
import 'dart:io';
import 'dart:typed_data';
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:path/path.dart' as p;

View File

@ -13,7 +13,7 @@ import 'render_lottie.dart';
class RawLottie extends LeafRenderObjectWidget {
/// Creates a widget that displays a Lottie composition.
const RawLottie({
Key? key,
super.key,
this.composition,
this.delegates,
this.options,
@ -25,8 +25,7 @@ class RawLottie extends LeafRenderObjectWidget {
AlignmentGeometry? alignment,
this.filterQuality,
}) : progress = progress ?? 0.0,
alignment = alignment ?? Alignment.center,
super(key: key);
alignment = alignment ?? Alignment.center;
/// The Lottie composition to display.
final LottieComposition? composition;

View File

@ -1,4 +1,3 @@
import 'dart:typed_data';
import 'dart:ui';
import 'package:flutter/foundation.dart';

View File

@ -33,7 +33,7 @@ class DropShadow {
}
@override
int get hashCode => hashValues(color, direction, distance, radius);
int get hashCode => Object.hash(color, direction, distance, radius);
@override
String toString() => 'DropShadow(color: $color, direction: $direction, '

View File

@ -1,4 +1,3 @@
import 'dart:ui';
import 'package:flutter/animation.dart';
import '../composition.dart';

View File

@ -7,21 +7,21 @@ packages:
name: _fe_analyzer_shared
url: "https://pub.dartlang.org"
source: hosted
version: "43.0.0"
version: "50.0.0"
analyzer:
dependency: "direct dev"
description:
name: analyzer
url: "https://pub.dartlang.org"
source: hosted
version: "4.3.1"
version: "5.2.0"
archive:
dependency: "direct main"
description:
name: archive
url: "https://pub.dartlang.org"
source: hosted
version: "3.3.1"
version: "3.3.2"
args:
dependency: transitive
description:
@ -35,7 +35,7 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.8.2"
version: "2.9.0"
boolean_selector:
dependency: transitive
description:
@ -49,14 +49,14 @@ packages:
name: build
url: "https://pub.dartlang.org"
source: hosted
version: "2.3.0"
version: "2.3.1"
build_config:
dependency: transitive
description:
name: build_config
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.1.1"
build_daemon:
dependency: transitive
description:
@ -70,21 +70,21 @@ packages:
name: build_resolvers
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.9"
version: "2.1.0"
build_runner:
dependency: "direct dev"
description:
name: build_runner
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.0"
version: "2.3.2"
build_runner_core:
dependency: transitive
description:
name: build_runner_core
url: "https://pub.dartlang.org"
source: hosted
version: "7.2.3"
version: "7.2.7"
built_collection:
dependency: transitive
description:
@ -98,21 +98,14 @@ packages:
name: built_value
url: "https://pub.dartlang.org"
source: hosted
version: "8.4.0"
version: "8.4.2"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.1"
version: "1.2.1"
checked_yaml:
dependency: transitive
description:
@ -126,14 +119,14 @@ packages:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.1.1"
code_builder:
dependency: transitive
description:
name: code_builder
url: "https://pub.dartlang.org"
source: hosted
version: "4.1.0"
version: "4.3.0"
collection:
dependency: transitive
description:
@ -147,7 +140,7 @@ packages:
name: convert
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.2"
version: "3.1.1"
crypto:
dependency: transitive
description:
@ -161,21 +154,21 @@ packages:
name: dart_style
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.3"
version: "2.2.4"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "1.3.1"
file:
dependency: transitive
description:
name: file
url: "https://pub.dartlang.org"
source: hosted
version: "6.1.2"
version: "6.1.4"
fixnum:
dependency: transitive
description:
@ -206,21 +199,21 @@ packages:
name: frontend_server_client
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.3"
version: "3.1.0"
glob:
dependency: transitive
description:
name: glob
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
version: "2.1.1"
graphs:
dependency: transitive
description:
name: graphs
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
version: "2.2.0"
http_multi_server:
dependency: transitive
description:
@ -234,7 +227,7 @@ packages:
name: http_parser
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.1"
version: "4.0.2"
io:
dependency: transitive
description:
@ -248,49 +241,49 @@ packages:
name: js
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.4"
version: "0.6.5"
json_annotation:
dependency: transitive
description:
name: json_annotation
url: "https://pub.dartlang.org"
source: hosted
version: "4.6.0"
version: "4.7.0"
lints:
dependency: transitive
description:
name: lints
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.0.1"
logging:
dependency: transitive
description:
name: logging
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.2"
version: "1.1.0"
matcher:
dependency: transitive
description:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.11"
version: "0.12.12"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.4"
version: "0.1.5"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.0"
version: "1.8.0"
mime:
dependency: transitive
description:
@ -311,7 +304,7 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.1"
version: "1.8.2"
pool:
dependency: transitive
description:
@ -325,28 +318,28 @@ packages:
name: pub_semver
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
version: "2.1.2"
pubspec_parse:
dependency: transitive
description:
name: pubspec_parse
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.2.1"
shelf:
dependency: transitive
description:
name: shelf
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.1"
version: "1.4.0"
shelf_web_socket:
dependency: transitive
description:
name: shelf_web_socket
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.2"
version: "1.0.3"
sky_engine:
dependency: transitive
description: flutter
@ -358,7 +351,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.2"
version: "1.9.0"
stack_trace:
dependency: transitive
description:
@ -379,28 +372,28 @@ packages:
name: stream_transform
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.1.0"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.1.1"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.2.1"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.9"
version: "0.4.12"
timing:
dependency: transitive
description:
@ -428,7 +421,7 @@ packages:
name: watcher
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
version: "1.0.2"
web_socket_channel:
dependency: transitive
description:
@ -444,5 +437,5 @@ packages:
source: hosted
version: "3.1.1"
sdks:
dart: ">=2.17.0 <3.0.0"
flutter: ">=2.10.0"
dart: ">=2.18.0 <3.0.0"
flutter: ">=3.3.0"

View File

@ -1,11 +1,11 @@
name: lottie
description: Render After Effects animations natively on Flutter. This package is a pure Dart implementation of a Lottie player.
version: 1.4.1
homepage: https://github.com/xvrh/lottie-flutter
version: 2.0.0
repository: https://github.com/xvrh/lottie-flutter
environment:
sdk: '>=2.12.0 <3.0.0'
flutter: '>=2.10.0'
sdk: '>=2.18.0 <3.0.0'
flutter: '>=3.3.0'
dependencies:
archive: ^3.0.0

View File

@ -291,7 +291,7 @@ void main() {
'Blur',
ValueDelegate.blurRadius(
['**'],
value: 22,
value: 10,
),
);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Some files were not shown because too many files have changed in this diff Show More