Compare commits

..

1 Commits

Author SHA1 Message Date
27b2ec471f Add errorBuilder 2020-10-12 22:07:03 +02:00
13 changed files with 84 additions and 114 deletions

View File

@ -10,7 +10,7 @@ jobs:
name: Flutter analyze name: Flutter analyze
strategy: strategy:
matrix: matrix:
flutter: ['stable'] flutter: ['stable', 'dev']
runs-on: macos-latest runs-on: macos-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2

View File

@ -1,6 +1,3 @@
## [0.7.0]
- Performance improvement for complex animations.
## [0.6.0] ## [0.6.0]
- Runs the animation at the frame rate specified in the json file (ie. An animation encoded with a 20 FPS will only - Runs the animation at the frame rate specified in the json file (ie. An animation encoded with a 20 FPS will only
be paint 20 times per seconds even though the AnimationController will invalidate the widget 60 times per seconds). be paint 20 times per seconds even though the AnimationController will invalidate the widget 60 times per seconds).

View File

@ -21,42 +21,42 @@ packages:
name: async name: async
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.5.0-nullsafety.1" version: "2.4.2"
boolean_selector: boolean_selector:
dependency: transitive dependency: transitive
description: description:
name: boolean_selector name: boolean_selector
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0-nullsafety.1" version: "2.0.0"
characters: characters:
dependency: transitive dependency: transitive
description: description:
name: characters name: characters
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0-nullsafety.3" version: "1.0.0"
charcode: charcode:
dependency: transitive dependency: transitive
description: description:
name: charcode name: charcode
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0-nullsafety.1" version: "1.1.3"
clock: clock:
dependency: transitive dependency: transitive
description: description:
name: clock name: clock
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0-nullsafety.1" version: "1.0.1"
collection: collection:
dependency: transitive dependency: transitive
description: description:
name: collection name: collection
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.15.0-nullsafety.3" version: "1.14.13"
convert: convert:
dependency: transitive dependency: transitive
description: description:
@ -77,14 +77,7 @@ packages:
name: fake_async name: fake_async
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0-nullsafety.1" version: "1.1.0"
ffi:
dependency: transitive
description:
name: ffi
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
file: file:
dependency: transitive dependency: transitive
description: description:
@ -150,35 +143,35 @@ packages:
path: ".." path: ".."
relative: true relative: true
source: path source: path
version: "0.7.0" version: "0.6.0"
matcher: matcher:
dependency: transitive dependency: transitive
description: description:
name: matcher name: matcher
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.12.10-nullsafety.1" version: "0.12.8"
meta: meta:
dependency: transitive dependency: transitive
description: description:
name: meta name: meta
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.3.0-nullsafety.3" version: "1.1.8"
path: path:
dependency: transitive dependency: transitive
description: description:
name: path name: path
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.0-nullsafety.1" version: "1.7.0"
path_provider: path_provider:
dependency: "direct main" dependency: "direct main"
description: description:
name: path_provider name: path_provider
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.6.21" version: "1.6.14"
path_provider_linux: path_provider_linux:
dependency: transitive dependency: transitive
description: description:
@ -192,7 +185,7 @@ packages:
name: path_provider_macos name: path_provider_macos
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.0.4+4" version: "0.0.4+3"
path_provider_platform_interface: path_provider_platform_interface:
dependency: transitive dependency: transitive
description: description:
@ -200,20 +193,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.3" version: "1.0.3"
path_provider_windows:
dependency: transitive
description:
name: path_provider_windows
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.4+1"
pedantic: pedantic:
dependency: transitive dependency: transitive
description: description:
name: pedantic name: pedantic
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.9.2" version: "1.9.0"
platform: platform:
dependency: transitive dependency: transitive
description: description:
@ -227,7 +213,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: "1.0.3" version: "1.0.2"
process: process:
dependency: transitive dependency: transitive
description: description:
@ -246,70 +232,63 @@ packages:
name: source_span name: source_span
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.0-nullsafety.2" version: "1.7.0"
stack_trace: stack_trace:
dependency: transitive dependency: transitive
description: description:
name: stack_trace name: stack_trace
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.10.0-nullsafety.1" version: "1.9.5"
stream_channel: stream_channel:
dependency: transitive dependency: transitive
description: description:
name: stream_channel name: stream_channel
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0-nullsafety.1" version: "2.0.0"
string_scanner: string_scanner:
dependency: transitive dependency: transitive
description: description:
name: string_scanner name: string_scanner
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0-nullsafety.1" version: "1.0.5"
term_glyph: term_glyph:
dependency: transitive dependency: transitive
description: description:
name: term_glyph name: term_glyph
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0-nullsafety.1" version: "1.1.0"
test_api: test_api:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.2.19-nullsafety.2" version: "0.2.17"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
name: typed_data name: typed_data
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.3.0-nullsafety.3" version: "1.2.0"
vector_math: vector_math:
dependency: transitive dependency: transitive
description: description:
name: vector_math name: vector_math
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0-nullsafety.3" version: "2.0.8"
win32:
dependency: transitive
description:
name: win32
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.3"
xdg_directories: xdg_directories:
dependency: transitive dependency: transitive
description: description:
name: xdg_directories name: xdg_directories
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.1.2" version: "0.1.0"
sdks: sdks:
dart: ">=2.10.0-110 <2.11.0" dart: ">=2.9.0-14.0.dev <3.0.0"
flutter: ">=1.12.13+hotfix.5 <2.0.0" flutter: ">=1.12.13+hotfix.5 <2.0.0"

View File

@ -8,11 +8,11 @@ environment:
dependencies: dependencies:
flutter: flutter:
sdk: flutter sdk: flutter
flutter_colorpicker:
http:
lottie: lottie:
path: ../ path: ../
flutter_colorpicker:
path_provider: path_provider:
http:
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.5 KiB

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -50,6 +50,7 @@ class Lottie extends StatefulWidget {
Key key, Key key,
AssetBundle bundle, AssetBundle bundle,
LottieFrameBuilder frameBuilder, LottieFrameBuilder frameBuilder,
LottieErrorWidgetBuilder errorBuilder,
double width, double width,
double height, double height,
BoxFit fit, BoxFit fit,
@ -71,6 +72,7 @@ class Lottie extends StatefulWidget {
key: key, key: key,
bundle: bundle, bundle: bundle,
frameBuilder: frameBuilder, frameBuilder: frameBuilder,
errorBuilder: errorBuilder,
width: width, width: width,
height: height, height: height,
fit: fit, fit: fit,
@ -93,6 +95,7 @@ class Lottie extends StatefulWidget {
void Function(LottieComposition) onLoaded, void Function(LottieComposition) onLoaded,
Key key, Key key,
LottieFrameBuilder frameBuilder, LottieFrameBuilder frameBuilder,
LottieErrorWidgetBuilder errorBuilder,
double width, double width,
double height, double height,
BoxFit fit, BoxFit fit,
@ -112,6 +115,7 @@ class Lottie extends StatefulWidget {
onLoaded: onLoaded, onLoaded: onLoaded,
key: key, key: key,
frameBuilder: frameBuilder, frameBuilder: frameBuilder,
errorBuilder: errorBuilder,
width: width, width: width,
height: height, height: height,
fit: fit, fit: fit,
@ -133,6 +137,7 @@ class Lottie extends StatefulWidget {
void Function(LottieComposition) onLoaded, void Function(LottieComposition) onLoaded,
Key key, Key key,
LottieFrameBuilder frameBuilder, LottieFrameBuilder frameBuilder,
LottieErrorWidgetBuilder errorBuilder,
double width, double width,
double height, double height,
BoxFit fit, BoxFit fit,
@ -152,6 +157,7 @@ class Lottie extends StatefulWidget {
onLoaded: onLoaded, onLoaded: onLoaded,
key: key, key: key,
frameBuilder: frameBuilder, frameBuilder: frameBuilder,
errorBuilder: errorBuilder,
width: width, width: width,
height: height, height: height,
fit: fit, fit: fit,
@ -173,6 +179,7 @@ class Lottie extends StatefulWidget {
void Function(LottieComposition) onLoaded, void Function(LottieComposition) onLoaded,
Key key, Key key,
LottieFrameBuilder frameBuilder, LottieFrameBuilder frameBuilder,
LottieErrorWidgetBuilder errorBuilder,
double width, double width,
double height, double height,
BoxFit fit, BoxFit fit,
@ -192,6 +199,7 @@ class Lottie extends StatefulWidget {
onLoaded: onLoaded, onLoaded: onLoaded,
key: key, key: key,
frameBuilder: frameBuilder, frameBuilder: frameBuilder,
errorBuilder: errorBuilder,
width: width, width: width,
height: height, height: height,
fit: fit, fit: fit,

View File

@ -44,6 +44,7 @@ class LottieBuilder extends StatefulWidget {
this.options, this.options,
this.onLoaded, this.onLoaded,
this.frameBuilder, this.frameBuilder,
this.errorBuilder,
this.width, this.width,
this.height, this.height,
this.fit, this.fit,
@ -67,6 +68,7 @@ class LottieBuilder extends StatefulWidget {
this.onLoaded, this.onLoaded,
Key key, Key key,
this.frameBuilder, this.frameBuilder,
this.errorBuilder,
this.width, this.width,
this.height, this.height,
this.fit, this.fit,
@ -99,6 +101,7 @@ class LottieBuilder extends StatefulWidget {
this.onLoaded, this.onLoaded,
Key key, Key key,
this.frameBuilder, this.frameBuilder,
this.errorBuilder,
this.width, this.width,
this.height, this.height,
this.fit, this.fit,
@ -122,6 +125,7 @@ class LottieBuilder extends StatefulWidget {
Key key, Key key,
AssetBundle bundle, AssetBundle bundle,
this.frameBuilder, this.frameBuilder,
this.errorBuilder,
this.width, this.width,
this.height, this.height,
this.fit, this.fit,
@ -148,6 +152,7 @@ class LottieBuilder extends StatefulWidget {
this.onLoaded, this.onLoaded,
Key key, Key key,
this.frameBuilder, this.frameBuilder,
this.errorBuilder,
this.width, this.width,
this.height, this.height,
this.fit, this.fit,
@ -279,6 +284,12 @@ class LottieBuilder extends StatefulWidget {
/// ///
final LottieFrameBuilder frameBuilder; final LottieFrameBuilder frameBuilder;
/// A builder function that is called if an error occurs during animation loading.
///
/// If this builder is not provided, it will use the `ErrorWidget` in debug mode
/// and an empty box in release mode.
final LottieErrorWidgetBuilder errorBuilder;
/// If non-null, require the lottie animation to have this width. /// If non-null, require the lottie animation to have this width.
/// ///
/// If null, the lottie animation will pick a size that best preserves its intrinsic /// If null, the lottie animation will pick a size that best preserves its intrinsic
@ -351,6 +362,7 @@ class LottieBuilder extends StatefulWidget {
super.debugFillProperties(properties); super.debugFillProperties(properties);
properties.add(DiagnosticsProperty<LottieProvider>('lottie', lottie)); properties.add(DiagnosticsProperty<LottieProvider>('lottie', lottie));
properties.add(DiagnosticsProperty<Function>('frameBuilder', frameBuilder)); properties.add(DiagnosticsProperty<Function>('frameBuilder', frameBuilder));
properties.add(DiagnosticsProperty<Function>('errorBuilder', errorBuilder));
properties.add(DoubleProperty('width', width, defaultValue: null)); properties.add(DoubleProperty('width', width, defaultValue: null));
properties.add(DoubleProperty('height', height, defaultValue: null)); properties.add(DoubleProperty('height', height, defaultValue: null));
properties.add(EnumProperty<BoxFit>('fit', fit, defaultValue: null)); properties.add(EnumProperty<BoxFit>('fit', fit, defaultValue: null));
@ -396,7 +408,9 @@ class _LottieBuilderState extends State<LottieBuilder> {
future: _loadingFuture, future: _loadingFuture,
builder: (context, snapshot) { builder: (context, snapshot) {
if (snapshot.hasError) { if (snapshot.hasError) {
if (kDebugMode) { if (widget.errorBuilder != null) {
return widget.errorBuilder(context, snapshot.error);
} else if (kDebugMode) {
return ErrorWidget(snapshot.error); return ErrorWidget(snapshot.error);
} }
} }
@ -435,3 +449,10 @@ class _LottieBuilderState extends State<LottieBuilder> {
'loadingFuture', _loadingFuture)); 'loadingFuture', _loadingFuture));
} }
} }
/// Signature used by [Lottie.errorBuilder] to create a replacement widget to
/// render instead of the Lottie animation.
typedef LottieErrorWidgetBuilder = Widget Function(
BuildContext context,
Object error,
);

View File

@ -7,14 +7,14 @@ packages:
name: _fe_analyzer_shared name: _fe_analyzer_shared
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "11.0.0" version: "6.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: "0.40.4" version: "0.39.14"
archive: archive:
dependency: "direct main" dependency: "direct main"
description: description:
@ -43,27 +43,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0-nullsafety.1" version: "2.1.0-nullsafety.1"
build:
dependency: transitive
description:
name: build
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.0"
built_collection:
dependency: transitive
description:
name: built_collection
url: "https://pub.dartlang.org"
source: hosted
version: "4.3.2"
built_value:
dependency: transitive
description:
name: built_value
url: "https://pub.dartlang.org"
source: hosted
version: "7.1.0"
characters: characters:
dependency: "direct main" dependency: "direct main"
description: description:
@ -84,7 +63,7 @@ packages:
name: cli_util name: cli_util
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.2.0" version: "0.1.4"
clock: clock:
dependency: transitive dependency: transitive
description: description:
@ -92,13 +71,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0-nullsafety.1" version: "1.1.0-nullsafety.1"
code_builder:
dependency: transitive
description:
name: code_builder
url: "https://pub.dartlang.org"
source: hosted
version: "3.5.0"
collection: collection:
dependency: "direct main" dependency: "direct main"
description: description:
@ -120,13 +92,20 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.5" version: "2.1.5"
csslib:
dependency: transitive
description:
name: csslib
url: "https://pub.dartlang.org"
source: hosted
version: "0.16.2"
dart_style: dart_style:
dependency: "direct dev" dependency: "direct dev"
description: description:
name: dart_style name: dart_style
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.3.8" version: "1.3.6"
fake_async: fake_async:
dependency: transitive dependency: transitive
description: description:
@ -134,13 +113,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0-nullsafety.1" version: "1.2.0-nullsafety.1"
fixnum:
dependency: transitive
description:
name: fixnum
url: "https://pub.dartlang.org"
source: hosted
version: "0.10.11"
flutter: flutter:
dependency: "direct main" dependency: "direct main"
description: flutter description: flutter
@ -158,6 +130,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" version: "1.2.0"
html:
dependency: transitive
description:
name: html
url: "https://pub.dartlang.org"
source: hosted
version: "0.14.0+3"
js: js:
dependency: transitive dependency: transitive
description: description:
@ -192,7 +171,7 @@ packages:
name: mockito name: mockito
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.1.3" version: "4.1.1"
node_interop: node_interop:
dependency: transitive dependency: transitive
description: description:
@ -227,7 +206,7 @@ packages:
name: pedantic name: pedantic
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.9.2" version: "1.9.0"
pub_semver: pub_semver:
dependency: transitive dependency: transitive
description: description:
@ -235,25 +214,11 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.4.4" version: "1.4.4"
quiver:
dependency: transitive
description:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.3"
sky_engine: sky_engine:
dependency: transitive dependency: transitive
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.99" version: "0.0.99"
source_gen:
dependency: transitive
description:
name: source_gen
url: "https://pub.dartlang.org"
source: hosted
version: "0.9.7+1"
source_span: source_span:
dependency: transitive dependency: transitive
description: description:

View File

@ -1,27 +1,27 @@
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: 0.7.0 version: 0.6.0
homepage: https://github.com/xvrh/lottie-flutter homepage: https://github.com/xvrh/lottie-flutter
environment: environment:
sdk: ">=2.7.0 <3.0.0" sdk: ">=2.7.0 <3.0.0"
dependencies: dependencies:
flutter:
sdk: flutter
archive: ^2.0.0 archive: ^2.0.0
characters: '>=0.5.0 <2.0.0' characters: '>=0.5.0 <2.0.0'
charcode: ^1.0.0 charcode: ^1.0.0
collection: ^1.14.0 collection: ^1.14.0
flutter:
sdk: flutter
logging: ^0.11.0 logging: ^0.11.0
meta: ^1.1.8 meta: ^1.1.8
path: ^1.6.0 path: ^1.6.0
vector_math: ^2.0.0 vector_math: ^2.0.0
dev_dependencies: dev_dependencies:
analyzer:
dart_style:
flutter_test: flutter_test:
sdk: flutter sdk: flutter
mockito: analyzer: 0.39.14
dart_style: 1.3.6
mockito: ^4.0.0
yaml: yaml: