Compare commits

...

3 Commits

441 changed files with 333 additions and 338 deletions

View File

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

View File

@ -1,3 +1,25 @@
## [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] ## [1.4.3]
- Fixed some lints with Flutter 3.3. - Fixed some lints with Flutter 3.3.

View File

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

View File

@ -10,14 +10,16 @@ linter:
always_declare_return_types: true always_declare_return_types: true
avoid_dynamic_calls: true avoid_dynamic_calls: true
avoid_escaping_inner_quotes: true avoid_escaping_inner_quotes: true
avoid_returning_null_for_future: true
avoid_setters_without_getters: true avoid_setters_without_getters: true
cancel_subscriptions: true
cast_nullable_to_non_nullable: true cast_nullable_to_non_nullable: true
close_sinks: true close_sinks: true
no_adjacent_strings_in_list: true no_adjacent_strings_in_list: true
no_default_cases: true no_default_cases: true
omit_local_variable_types: true omit_local_variable_types: true
only_throw_errors: true only_throw_errors: true
prefer_interpolation_to_compose_strings: true prefer_relative_imports: true
prefer_single_quotes: true prefer_single_quotes: true
sort_child_properties_last: true sort_child_properties_last: true
sort_pub_dependencies: true sort_pub_dependencies: true
@ -27,3 +29,4 @@ linter:
unnecessary_statements: true unnecessary_statements: true
unsafe_html: true unsafe_html: true
use_raw_strings: 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()); void main() => runApp(const MyApp());
class MyApp extends StatelessWidget { class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key); const MyApp({super.key});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -6,7 +6,7 @@ void main() async {
} }
class App extends StatelessWidget { class App extends StatelessWidget {
const App({Key? key}) : super(key: key); const App({super.key});
@override @override
Widget build(BuildContext context) { 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 :path: Flutter/ephemeral/.symlinks/plugins/path_provider_macos/macos
SPEC CHECKSUMS: SPEC CHECKSUMS:
FlutterMacOS: 57701585bf7de1b3fc2bb61f6378d73bbdea8424 FlutterMacOS: ae6af50a8ea7d6103d888583d46bd8328a7e9811
path_provider_macos: 160cab0d5461f0c0e02995469a98f24bdb9a3f1f path_provider_macos: 3c0c3b4b0d4a76d2bf989a913c2de869c5641a19
PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c

View File

@ -7,7 +7,7 @@ packages:
name: archive name: archive
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.3.1" version: "3.3.2"
async: async:
dependency: transitive dependency: transitive
description: description:
@ -115,28 +115,28 @@ packages:
name: http_parser name: http_parser
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.0.1" version: "4.0.2"
lints: lints:
dependency: transitive dependency: transitive
description: description:
name: lints name: lints
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.0" version: "2.0.1"
logging: logging:
dependency: "direct main" dependency: "direct main"
description: description:
name: logging name: logging
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.2" version: "1.1.0"
lottie: lottie:
dependency: "direct main" dependency: "direct main"
description: description:
path: ".." path: ".."
relative: true relative: true
source: path source: path
version: "1.4.3" version: "2.0.0"
matcher: matcher:
dependency: transitive dependency: transitive
description: description:
@ -178,7 +178,7 @@ packages:
name: path_provider_android name: path_provider_android
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.20" version: "2.0.21"
path_provider_ios: path_provider_ios:
dependency: transitive dependency: transitive
description: description:
@ -206,7 +206,7 @@ packages:
name: path_provider_platform_interface name: path_provider_platform_interface
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.4" version: "2.0.5"
path_provider_windows: path_provider_windows:
dependency: transitive dependency: transitive
description: description:
@ -227,7 +227,7 @@ packages:
name: plugin_platform_interface name: plugin_platform_interface
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.2" version: "2.1.3"
process: process:
dependency: transitive dependency: transitive
description: description:
@ -302,7 +302,7 @@ packages:
name: win32 name: win32
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.0.0" version: "3.1.1"
xdg_directories: xdg_directories:
dependency: transitive dependency: transitive
description: description:

View File

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

View File

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

View File

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

View File

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

View File

@ -1,7 +1,6 @@
import '../../value/keyframe.dart';
import 'base_keyframe_animation.dart'; import 'base_keyframe_animation.dart';
abstract class KeyframeAnimation<T extends Object> abstract class KeyframeAnimation<T extends Object>
extends BaseKeyframeAnimation<T, T> { 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; Path? _path;
final Keyframe<Offset> _pointKeyFrame; final Keyframe<Offset> _pointKeyFrame;
PathKeyframe(LottieComposition composition, Keyframe<Offset> keyframe) PathKeyframe(LottieComposition super.composition, Keyframe<Offset> keyframe)
: _pointKeyFrame = keyframe, : _pointKeyFrame = keyframe,
super(composition, super(
startValue: keyframe.startValue, startValue: keyframe.startValue,
endValue: keyframe.endValue, endValue: keyframe.endValue,
interpolator: keyframe.interpolator, interpolator: keyframe.interpolator,

View File

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

View File

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

View File

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

View File

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

View File

@ -12,7 +12,7 @@ import 'lottie_builder.dart';
/// [repeat] and [reverse]. /// [repeat] and [reverse].
class Lottie extends StatefulWidget { class Lottie extends StatefulWidget {
const Lottie({ const Lottie({
Key? key, super.key,
required this.composition, required this.composition,
this.controller, this.controller,
this.width, this.width,
@ -30,8 +30,7 @@ class Lottie extends StatefulWidget {
}) : animate = animate ?? true, }) : animate = animate ?? true,
reverse = reverse ?? false, reverse = reverse ?? false,
repeat = repeat ?? true, repeat = repeat ?? true,
addRepaintBoundary = addRepaintBoundary ?? true, addRepaintBoundary = addRepaintBoundary ?? true;
super(key: key);
/// Creates a widget that displays an [LottieComposition] obtained from an [AssetBundle]. /// Creates a widget that displays an [LottieComposition] obtained from an [AssetBundle].
static LottieBuilder asset( static LottieBuilder asset(

View File

@ -41,7 +41,7 @@ typedef LottieErrorWidgetBuilder = Widget Function(
/// ///
class LottieBuilder extends StatefulWidget { class LottieBuilder extends StatefulWidget {
const LottieBuilder({ const LottieBuilder({
Key? key, super.key,
required this.lottie, required this.lottie,
this.controller, this.controller,
this.frameRate, this.frameRate,
@ -60,7 +60,7 @@ class LottieBuilder extends StatefulWidget {
this.addRepaintBoundary, this.addRepaintBoundary,
this.filterQuality, this.filterQuality,
this.onWarning, this.onWarning,
}) : super(key: key); });
/// Creates a widget that displays an [LottieComposition] obtained from the network. /// Creates a widget that displays an [LottieComposition] obtained from the network.
LottieBuilder.network( LottieBuilder.network(
@ -75,7 +75,7 @@ class LottieBuilder extends StatefulWidget {
this.options, this.options,
LottieImageProviderFactory? imageProviderFactory, LottieImageProviderFactory? imageProviderFactory,
this.onLoaded, this.onLoaded,
Key? key, super.key,
this.frameBuilder, this.frameBuilder,
this.errorBuilder, this.errorBuilder,
this.width, this.width,
@ -86,8 +86,7 @@ class LottieBuilder extends StatefulWidget {
this.filterQuality, this.filterQuality,
this.onWarning, this.onWarning,
}) : lottie = NetworkLottie(src, }) : lottie = NetworkLottie(src,
headers: headers, imageProviderFactory: imageProviderFactory), headers: headers, imageProviderFactory: imageProviderFactory);
super(key: key);
/// Creates a widget that displays an [LottieComposition] obtained from a [File]. /// Creates a widget that displays an [LottieComposition] obtained from a [File].
/// ///
@ -110,7 +109,7 @@ class LottieBuilder extends StatefulWidget {
this.options, this.options,
LottieImageProviderFactory? imageProviderFactory, LottieImageProviderFactory? imageProviderFactory,
this.onLoaded, this.onLoaded,
Key? key, super.key,
this.frameBuilder, this.frameBuilder,
this.errorBuilder, this.errorBuilder,
this.width, this.width,
@ -120,8 +119,7 @@ class LottieBuilder extends StatefulWidget {
this.addRepaintBoundary, this.addRepaintBoundary,
this.filterQuality, this.filterQuality,
this.onWarning, this.onWarning,
}) : lottie = FileLottie(file, imageProviderFactory: imageProviderFactory), }) : lottie = FileLottie(file, imageProviderFactory: imageProviderFactory);
super(key: key);
/// Creates a widget that displays an [LottieComposition] obtained from an [AssetBundle]. /// Creates a widget that displays an [LottieComposition] obtained from an [AssetBundle].
LottieBuilder.asset( LottieBuilder.asset(
@ -135,7 +133,7 @@ class LottieBuilder extends StatefulWidget {
this.options, this.options,
LottieImageProviderFactory? imageProviderFactory, LottieImageProviderFactory? imageProviderFactory,
this.onLoaded, this.onLoaded,
Key? key, super.key,
AssetBundle? bundle, AssetBundle? bundle,
this.frameBuilder, this.frameBuilder,
this.errorBuilder, this.errorBuilder,
@ -150,8 +148,7 @@ class LottieBuilder extends StatefulWidget {
}) : lottie = AssetLottie(name, }) : lottie = AssetLottie(name,
bundle: bundle, bundle: bundle,
package: package, package: package,
imageProviderFactory: imageProviderFactory), imageProviderFactory: imageProviderFactory);
super(key: key);
/// Creates a widget that displays an [LottieComposition] obtained from a [Uint8List]. /// Creates a widget that displays an [LottieComposition] obtained from a [Uint8List].
LottieBuilder.memory( LottieBuilder.memory(
@ -166,7 +163,7 @@ class LottieBuilder extends StatefulWidget {
LottieImageProviderFactory? imageProviderFactory, LottieImageProviderFactory? imageProviderFactory,
this.onLoaded, this.onLoaded,
this.errorBuilder, this.errorBuilder,
Key? key, super.key,
this.frameBuilder, this.frameBuilder,
this.width, this.width,
this.height, this.height,
@ -175,9 +172,7 @@ class LottieBuilder extends StatefulWidget {
this.addRepaintBoundary, this.addRepaintBoundary,
this.filterQuality, this.filterQuality,
this.onWarning, this.onWarning,
}) : lottie = }) : lottie = MemoryLottie(bytes, imageProviderFactory: imageProviderFactory);
MemoryLottie(bytes, imageProviderFactory: imageProviderFactory),
super(key: key);
/// The lottie animation to load. /// The lottie animation to load.
/// Example of providers: [AssetLottie], [NetworkLottie], [FileLottie], [MemoryLottie] /// Example of providers: [AssetLottie], [NetworkLottie], [FileLottie], [MemoryLottie]

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -26,7 +26,7 @@ class GradientColorParser {
/// opacity, /// opacity,
/// ... /// ...
/// ] /// ]
GradientColor parse(JsonReader reader, {required double scale}) { GradientColor parse(JsonReader reader) {
var array = <double>[]; var array = <double>[];
// The array was started by Keyframe because it thought that this may be an array of keyframes // 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. // 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 'json_utils.dart';
import 'moshi/json_reader.dart'; import 'moshi/json_reader.dart';
int integerParser(JsonReader reader, {required double scale}) { int integerParser(JsonReader reader) {
return (JsonUtils.valueFromObject(reader) * scale).round(); return JsonUtils.valueFromObject(reader).round();
} }

View File

@ -14,43 +14,43 @@ class JsonUtils {
return Color.fromARGB(255, r, g, b); return Color.fromARGB(255, r, g, b);
} }
static List<Offset> jsonToPoints(JsonReader reader, double scale) { static List<Offset> jsonToPoints(JsonReader reader) {
var points = <Offset>[]; var points = <Offset>[];
reader.beginArray(); reader.beginArray();
while (reader.peek() == Token.beginArray) { while (reader.peek() == Token.beginArray) {
reader.beginArray(); reader.beginArray();
points.add(jsonToPoint(reader, scale)); points.add(jsonToPoint(reader));
reader.endArray(); reader.endArray();
} }
reader.endArray(); reader.endArray();
return points; return points;
} }
static Offset jsonToPoint(JsonReader reader, double scale) { static Offset jsonToPoint(JsonReader reader) {
switch (reader.peek()) { switch (reader.peek()) {
case Token.number: case Token.number:
return _jsonNumbersToPoint(reader, scale); return _jsonNumbersToPoint(reader);
case Token.beginArray: case Token.beginArray:
return _jsonArrayToPoint(reader, scale); return _jsonArrayToPoint(reader);
case Token.beginObject: case Token.beginObject:
return _jsonObjectToPoint(reader, scale: scale); return _jsonObjectToPoint(reader);
// ignore: no_default_cases // ignore: no_default_cases
default: default:
throw Exception('Unknown point starts with ${reader.peek()}'); 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 x = reader.nextDouble();
var y = reader.nextDouble(); var y = reader.nextDouble();
while (reader.hasNext()) { while (reader.hasNext()) {
reader.skipValue(); 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 x;
double y; double y;
reader.beginArray(); reader.beginArray();
@ -60,12 +60,12 @@ class JsonUtils {
reader.skipValue(); reader.skipValue();
} }
reader.endArray(); reader.endArray();
return Offset(x * scale, y * scale); return Offset(x, y);
} }
static final JsonReaderOptions _pointNames = JsonReaderOptions.of(['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 x = 0.0;
var y = 0.0; var y = 0.0;
reader.beginObject(); reader.beginObject();
@ -83,7 +83,7 @@ class JsonUtils {
} }
} }
reader.endObject(); reader.endObject();
return Offset(x * scale, y * scale); return Offset(x, y);
} }
static double valueFromObject(JsonReader reader) { 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. /// @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, static Keyframe<T> parse<T>(JsonReader reader, LottieComposition composition,
double scale, ValueParser<T> valueParser, ValueParser<T> valueParser,
{required bool animated, bool multiDimensional = false}) { {required bool animated, bool multiDimensional = false}) {
if (animated && multiDimensional) { if (animated && multiDimensional) {
return _parseMultiDimensionalKeyframe( return _parseMultiDimensionalKeyframe(composition, reader, valueParser);
composition, reader, scale, valueParser);
} else if (animated) { } else if (animated) {
return _parseKeyframe(composition, reader, scale, valueParser); return _parseKeyframe(composition, reader, valueParser);
} else { } else {
return _parseStaticValue(reader, scale, valueParser); return _parseStaticValue(reader, valueParser);
} }
} }
/// beginObject will already be called on the keyframe so it can be differentiated with /// beginObject will already be called on the keyframe so it can be differentiated with
/// a non animated value. /// a non animated value.
static Keyframe<T> _parseKeyframe<T>(LottieComposition composition, static Keyframe<T> _parseKeyframe<T>(LottieComposition composition,
JsonReader reader, double scale, ValueParser<T> valueParser) { JsonReader reader, ValueParser<T> valueParser) {
Offset? cp1; Offset? cp1;
Offset? cp2; Offset? cp2;
var startFrame = 0.0; var startFrame = 0.0;
@ -61,25 +60,25 @@ class KeyframeParser {
startFrame = reader.nextDouble(); startFrame = reader.nextDouble();
break; break;
case 1: case 1:
startValue = valueParser(reader, scale: scale); startValue = valueParser(reader);
break; break;
case 2: case 2:
endValue = valueParser(reader, scale: scale); endValue = valueParser(reader);
break; break;
case 3: case 3:
cp1 = JsonUtils.jsonToPoint(reader, 1); cp1 = JsonUtils.jsonToPoint(reader);
break; break;
case 4: case 4:
cp2 = JsonUtils.jsonToPoint(reader, 1); cp2 = JsonUtils.jsonToPoint(reader);
break; break;
case 5: case 5:
hold = reader.nextInt() == 1; hold = reader.nextInt() == 1;
break; break;
case 6: case 6:
pathCp1 = JsonUtils.jsonToPoint(reader, scale); pathCp1 = JsonUtils.jsonToPoint(reader);
break; break;
case 7: case 7:
pathCp2 = JsonUtils.jsonToPoint(reader, scale); pathCp2 = JsonUtils.jsonToPoint(reader);
break; break;
default: default:
reader.skipValue(); reader.skipValue();
@ -111,7 +110,6 @@ class KeyframeParser {
static Keyframe<T> _parseMultiDimensionalKeyframe<T>( static Keyframe<T> _parseMultiDimensionalKeyframe<T>(
LottieComposition composition, LottieComposition composition,
JsonReader reader, JsonReader reader,
double scale,
ValueParser<T> valueParser) { ValueParser<T> valueParser) {
Offset? cp1; Offset? cp1;
Offset? cp2; Offset? cp2;
@ -140,10 +138,10 @@ class KeyframeParser {
startFrame = reader.nextDouble(); startFrame = reader.nextDouble();
break; break;
case 1: // s case 1: // s
startValue = valueParser(reader, scale: scale); startValue = valueParser(reader);
break; break;
case 2: // e case 2: // e
endValue = valueParser(reader, scale: scale); endValue = valueParser(reader);
break; break;
case 3: // o case 3: // o
if (reader.peek() == Token.beginObject) { if (reader.peek() == Token.beginObject) {
@ -192,7 +190,7 @@ class KeyframeParser {
yCp1 = Offset(yCp1x, yCp1y); yCp1 = Offset(yCp1x, yCp1y);
reader.endObject(); reader.endObject();
} else { } else {
cp1 = JsonUtils.jsonToPoint(reader, scale); cp1 = JsonUtils.jsonToPoint(reader);
} }
break; break;
case 4: // i case 4: // i
@ -242,17 +240,17 @@ class KeyframeParser {
yCp2 = Offset(yCp2x, yCp2y); yCp2 = Offset(yCp2x, yCp2y);
reader.endObject(); reader.endObject();
} else { } else {
cp2 = JsonUtils.jsonToPoint(reader, scale); cp2 = JsonUtils.jsonToPoint(reader);
} }
break; break;
case 5: // h case 5: // h
hold = reader.nextInt() == 1; hold = reader.nextInt() == 1;
break; break;
case 6: // to case 6: // to
pathCp1 = JsonUtils.jsonToPoint(reader, scale); pathCp1 = JsonUtils.jsonToPoint(reader);
break; break;
case 7: // ti case 7: // ti
pathCp2 = JsonUtils.jsonToPoint(reader, scale); pathCp2 = JsonUtils.jsonToPoint(reader);
break; break;
default: default:
reader.skipValue(); reader.skipValue();
@ -322,8 +320,8 @@ class KeyframeParser {
} }
static Keyframe<T> _parseStaticValue<T>( static Keyframe<T> _parseStaticValue<T>(
JsonReader reader, double scale, ValueParser<T> valueParser) { JsonReader reader, ValueParser<T> valueParser) {
var value = valueParser(reader, scale: scale); var value = valueParser(reader);
return Keyframe<T>.nonAnimated(value); return Keyframe<T>.nonAnimated(value);
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,7 +1,7 @@
import 'dart:ui'; import 'dart:ui';
import 'moshi/json_reader.dart'; import 'moshi/json_reader.dart';
Offset scaleXYParser(JsonReader reader, {required double scale}) { Offset scaleXYParser(JsonReader reader) {
var isArray = reader.peek() == Token.beginArray; var isArray = reader.peek() == Token.beginArray;
if (isArray) { if (isArray) {
reader.beginArray(); reader.beginArray();
@ -14,5 +14,5 @@ Offset scaleXYParser(JsonReader reader, {required double scale}) {
if (isArray) { if (isArray) {
reader.endArray(); 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']); 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 // Sometimes the points data is in a array of length 1. Sometimes the data is at the top
// level. // level.
if (reader.peek() == Token.beginArray) { if (reader.peek() == Token.beginArray) {
@ -25,13 +25,13 @@ ShapeData shapeDataParser(JsonReader reader, {required double scale}) {
closed = reader.nextBoolean(); closed = reader.nextBoolean();
break; break;
case 1: case 1:
pointsArray = JsonUtils.jsonToPoints(reader, scale); pointsArray = JsonUtils.jsonToPoints(reader);
break; break;
case 2: case 2:
inTangents = JsonUtils.jsonToPoints(reader, scale); inTangents = JsonUtils.jsonToPoints(reader);
break; break;
case 3: case 3:
outTangents = JsonUtils.jsonToPoints(reader, scale); outTangents = JsonUtils.jsonToPoints(reader);
break; break;
default: default:
reader.skipName(); reader.skipName();

View File

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

View File

@ -1,3 +1,3 @@
import 'moshi/json_reader.dart'; 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.assetName, {
this.bundle, this.bundle,
this.package, this.package,
LottieImageProviderFactory? imageProviderFactory, super.imageProviderFactory,
}) : super(imageProviderFactory: imageProviderFactory); });
final String assetName; final String assetName;
String get keyName => String get keyName =>

View File

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

View File

@ -8,8 +8,7 @@ import 'load_image.dart';
import 'lottie_provider.dart'; import 'lottie_provider.dart';
class MemoryLottie extends LottieProvider { class MemoryLottie extends LottieProvider {
MemoryLottie(this.bytes, {LottieImageProviderFactory? imageProviderFactory}) MemoryLottie(this.bytes, {super.imageProviderFactory});
: super(imageProviderFactory: imageProviderFactory);
final Uint8List bytes; 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; import 'provider_io.dart' if (dart.library.html) 'provider_web.dart' as network;
class NetworkLottie extends LottieProvider { class NetworkLottie extends LottieProvider {
NetworkLottie(this.url, NetworkLottie(this.url, {this.headers, super.imageProviderFactory});
{this.headers, LottieImageProviderFactory? imageProviderFactory})
: super(imageProviderFactory: imageProviderFactory);
final String url; final String url;
final Map<String, String>? headers; final Map<String, String>? headers;

View File

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

View File

@ -7,21 +7,21 @@ packages:
name: _fe_analyzer_shared name: _fe_analyzer_shared
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "48.0.0" version: "50.0.0"
analyzer: analyzer:
dependency: "direct dev" dependency: "direct dev"
description: description:
name: analyzer name: analyzer
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "5.0.0" version: "5.2.0"
archive: archive:
dependency: "direct main" dependency: "direct main"
description: description:
name: archive name: archive
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.3.1" version: "3.3.2"
args: args:
dependency: transitive dependency: transitive
description: description:
@ -56,7 +56,7 @@ packages:
name: build_config name: build_config
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0" version: "1.1.1"
build_daemon: build_daemon:
dependency: transitive dependency: transitive
description: description:
@ -70,21 +70,21 @@ packages:
name: build_resolvers name: build_resolvers
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.10" version: "2.1.0"
build_runner: build_runner:
dependency: "direct dev" dependency: "direct dev"
description: description:
name: build_runner name: build_runner
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.2.1" version: "2.3.2"
build_runner_core: build_runner_core:
dependency: transitive dependency: transitive
description: description:
name: build_runner_core name: build_runner_core
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "7.2.4" version: "7.2.7"
built_collection: built_collection:
dependency: transitive dependency: transitive
description: description:
@ -98,7 +98,7 @@ packages:
name: built_value name: built_value
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "8.4.1" version: "8.4.2"
characters: characters:
dependency: transitive dependency: transitive
description: description:
@ -126,7 +126,7 @@ packages:
name: code_builder name: code_builder
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.2.0" version: "4.3.0"
collection: collection:
dependency: transitive dependency: transitive
description: description:
@ -140,7 +140,7 @@ packages:
name: convert name: convert
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.0.2" version: "3.1.1"
crypto: crypto:
dependency: transitive dependency: transitive
description: description:
@ -199,21 +199,21 @@ packages:
name: frontend_server_client name: frontend_server_client
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.3" version: "3.1.0"
glob: glob:
dependency: transitive dependency: transitive
description: description:
name: glob name: glob
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0" version: "2.1.1"
graphs: graphs:
dependency: transitive dependency: transitive
description: description:
name: graphs name: graphs
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0" version: "2.2.0"
http_multi_server: http_multi_server:
dependency: transitive dependency: transitive
description: description:
@ -227,7 +227,7 @@ packages:
name: http_parser name: http_parser
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.0.1" version: "4.0.2"
io: io:
dependency: transitive dependency: transitive
description: description:
@ -241,28 +241,28 @@ packages:
name: js name: js
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.6.4" version: "0.6.5"
json_annotation: json_annotation:
dependency: transitive dependency: transitive
description: description:
name: json_annotation name: json_annotation
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.6.0" version: "4.7.0"
lints: lints:
dependency: transitive dependency: transitive
description: description:
name: lints name: lints
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.0" version: "2.0.1"
logging: logging:
dependency: transitive dependency: transitive
description: description:
name: logging name: logging
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.2" version: "1.1.0"
matcher: matcher:
dependency: transitive dependency: transitive
description: description:
@ -318,7 +318,7 @@ packages:
name: pub_semver name: pub_semver
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.1" version: "2.1.2"
pubspec_parse: pubspec_parse:
dependency: transitive dependency: transitive
description: description:
@ -332,14 +332,14 @@ packages:
name: shelf name: shelf
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.3.2" version: "1.4.0"
shelf_web_socket: shelf_web_socket:
dependency: transitive dependency: transitive
description: description:
name: shelf_web_socket name: shelf_web_socket
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.2" version: "1.0.3"
sky_engine: sky_engine:
dependency: transitive dependency: transitive
description: flutter description: flutter
@ -372,7 +372,7 @@ packages:
name: stream_transform name: stream_transform
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.0" version: "2.1.0"
string_scanner: string_scanner:
dependency: transitive dependency: transitive
description: description:
@ -421,7 +421,7 @@ packages:
name: watcher name: watcher
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.1" version: "1.0.2"
web_socket_channel: web_socket_channel:
dependency: transitive dependency: transitive
description: description:

View File

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

View File

@ -291,7 +291,7 @@ void main() {
'Blur', 'Blur',
ValueDelegate.blurRadius( 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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 133 KiB

After

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

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