mirror of
https://github.com/xvrh/lottie-flutter.git
synced 2025-08-06 16:39:36 +08:00
Compare commits
1 Commits
v3.3.1
...
error_buil
Author | SHA1 | Date | |
---|---|---|---|
27b2ec471f |
@ -50,6 +50,7 @@ class Lottie extends StatefulWidget {
|
||||
Key key,
|
||||
AssetBundle bundle,
|
||||
LottieFrameBuilder frameBuilder,
|
||||
LottieErrorWidgetBuilder errorBuilder,
|
||||
double width,
|
||||
double height,
|
||||
BoxFit fit,
|
||||
@ -71,6 +72,7 @@ class Lottie extends StatefulWidget {
|
||||
key: key,
|
||||
bundle: bundle,
|
||||
frameBuilder: frameBuilder,
|
||||
errorBuilder: errorBuilder,
|
||||
width: width,
|
||||
height: height,
|
||||
fit: fit,
|
||||
@ -93,6 +95,7 @@ class Lottie extends StatefulWidget {
|
||||
void Function(LottieComposition) onLoaded,
|
||||
Key key,
|
||||
LottieFrameBuilder frameBuilder,
|
||||
LottieErrorWidgetBuilder errorBuilder,
|
||||
double width,
|
||||
double height,
|
||||
BoxFit fit,
|
||||
@ -112,6 +115,7 @@ class Lottie extends StatefulWidget {
|
||||
onLoaded: onLoaded,
|
||||
key: key,
|
||||
frameBuilder: frameBuilder,
|
||||
errorBuilder: errorBuilder,
|
||||
width: width,
|
||||
height: height,
|
||||
fit: fit,
|
||||
@ -133,6 +137,7 @@ class Lottie extends StatefulWidget {
|
||||
void Function(LottieComposition) onLoaded,
|
||||
Key key,
|
||||
LottieFrameBuilder frameBuilder,
|
||||
LottieErrorWidgetBuilder errorBuilder,
|
||||
double width,
|
||||
double height,
|
||||
BoxFit fit,
|
||||
@ -152,6 +157,7 @@ class Lottie extends StatefulWidget {
|
||||
onLoaded: onLoaded,
|
||||
key: key,
|
||||
frameBuilder: frameBuilder,
|
||||
errorBuilder: errorBuilder,
|
||||
width: width,
|
||||
height: height,
|
||||
fit: fit,
|
||||
@ -173,6 +179,7 @@ class Lottie extends StatefulWidget {
|
||||
void Function(LottieComposition) onLoaded,
|
||||
Key key,
|
||||
LottieFrameBuilder frameBuilder,
|
||||
LottieErrorWidgetBuilder errorBuilder,
|
||||
double width,
|
||||
double height,
|
||||
BoxFit fit,
|
||||
@ -192,6 +199,7 @@ class Lottie extends StatefulWidget {
|
||||
onLoaded: onLoaded,
|
||||
key: key,
|
||||
frameBuilder: frameBuilder,
|
||||
errorBuilder: errorBuilder,
|
||||
width: width,
|
||||
height: height,
|
||||
fit: fit,
|
||||
|
@ -44,6 +44,7 @@ class LottieBuilder extends StatefulWidget {
|
||||
this.options,
|
||||
this.onLoaded,
|
||||
this.frameBuilder,
|
||||
this.errorBuilder,
|
||||
this.width,
|
||||
this.height,
|
||||
this.fit,
|
||||
@ -67,6 +68,7 @@ class LottieBuilder extends StatefulWidget {
|
||||
this.onLoaded,
|
||||
Key key,
|
||||
this.frameBuilder,
|
||||
this.errorBuilder,
|
||||
this.width,
|
||||
this.height,
|
||||
this.fit,
|
||||
@ -99,6 +101,7 @@ class LottieBuilder extends StatefulWidget {
|
||||
this.onLoaded,
|
||||
Key key,
|
||||
this.frameBuilder,
|
||||
this.errorBuilder,
|
||||
this.width,
|
||||
this.height,
|
||||
this.fit,
|
||||
@ -122,6 +125,7 @@ class LottieBuilder extends StatefulWidget {
|
||||
Key key,
|
||||
AssetBundle bundle,
|
||||
this.frameBuilder,
|
||||
this.errorBuilder,
|
||||
this.width,
|
||||
this.height,
|
||||
this.fit,
|
||||
@ -148,6 +152,7 @@ class LottieBuilder extends StatefulWidget {
|
||||
this.onLoaded,
|
||||
Key key,
|
||||
this.frameBuilder,
|
||||
this.errorBuilder,
|
||||
this.width,
|
||||
this.height,
|
||||
this.fit,
|
||||
@ -279,6 +284,12 @@ class LottieBuilder extends StatefulWidget {
|
||||
///
|
||||
final LottieFrameBuilder frameBuilder;
|
||||
|
||||
/// A builder function that is called if an error occurs during animation loading.
|
||||
///
|
||||
/// If this builder is not provided, it will use the `ErrorWidget` in debug mode
|
||||
/// and an empty box in release mode.
|
||||
final LottieErrorWidgetBuilder errorBuilder;
|
||||
|
||||
/// If non-null, require the lottie animation to have this width.
|
||||
///
|
||||
/// If null, the lottie animation will pick a size that best preserves its intrinsic
|
||||
@ -351,6 +362,7 @@ class LottieBuilder extends StatefulWidget {
|
||||
super.debugFillProperties(properties);
|
||||
properties.add(DiagnosticsProperty<LottieProvider>('lottie', lottie));
|
||||
properties.add(DiagnosticsProperty<Function>('frameBuilder', frameBuilder));
|
||||
properties.add(DiagnosticsProperty<Function>('errorBuilder', errorBuilder));
|
||||
properties.add(DoubleProperty('width', width, defaultValue: null));
|
||||
properties.add(DoubleProperty('height', height, defaultValue: null));
|
||||
properties.add(EnumProperty<BoxFit>('fit', fit, defaultValue: null));
|
||||
@ -396,7 +408,9 @@ class _LottieBuilderState extends State<LottieBuilder> {
|
||||
future: _loadingFuture,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasError) {
|
||||
if (kDebugMode) {
|
||||
if (widget.errorBuilder != null) {
|
||||
return widget.errorBuilder(context, snapshot.error);
|
||||
} else if (kDebugMode) {
|
||||
return ErrorWidget(snapshot.error);
|
||||
}
|
||||
}
|
||||
@ -435,3 +449,10 @@ class _LottieBuilderState extends State<LottieBuilder> {
|
||||
'loadingFuture', _loadingFuture));
|
||||
}
|
||||
}
|
||||
|
||||
/// Signature used by [Lottie.errorBuilder] to create a replacement widget to
|
||||
/// render instead of the Lottie animation.
|
||||
typedef LottieErrorWidgetBuilder = Widget Function(
|
||||
BuildContext context,
|
||||
Object error,
|
||||
);
|
||||
|
38
pubspec.lock
38
pubspec.lock
@ -35,28 +35,28 @@ packages:
|
||||
name: async
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.4.2"
|
||||
version: "2.5.0-nullsafety.1"
|
||||
boolean_selector:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: boolean_selector
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.0"
|
||||
version: "2.1.0-nullsafety.1"
|
||||
characters:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: characters
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.0"
|
||||
version: "1.1.0-nullsafety.3"
|
||||
charcode:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: charcode
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.3"
|
||||
version: "1.2.0-nullsafety.1"
|
||||
cli_util:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -70,14 +70,14 @@ packages:
|
||||
name: clock
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.1"
|
||||
version: "1.1.0-nullsafety.1"
|
||||
collection:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: collection
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.14.13"
|
||||
version: "1.15.0-nullsafety.3"
|
||||
convert:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -112,7 +112,7 @@ packages:
|
||||
name: fake_async
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
version: "1.2.0-nullsafety.1"
|
||||
flutter:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
@ -157,14 +157,14 @@ packages:
|
||||
name: matcher
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.12.8"
|
||||
version: "0.12.10-nullsafety.1"
|
||||
meta:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: meta
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.8"
|
||||
version: "1.3.0-nullsafety.3"
|
||||
mockito:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
@ -199,7 +199,7 @@ packages:
|
||||
name: path
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.7.0"
|
||||
version: "1.8.0-nullsafety.1"
|
||||
pedantic:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -225,56 +225,56 @@ packages:
|
||||
name: source_span
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.7.0"
|
||||
version: "1.8.0-nullsafety.2"
|
||||
stack_trace:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: stack_trace
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.9.5"
|
||||
version: "1.10.0-nullsafety.1"
|
||||
stream_channel:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: stream_channel
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.0"
|
||||
version: "2.1.0-nullsafety.1"
|
||||
string_scanner:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: string_scanner
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.5"
|
||||
version: "1.1.0-nullsafety.1"
|
||||
term_glyph:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: term_glyph
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
version: "1.2.0-nullsafety.1"
|
||||
test_api:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_api
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.2.17"
|
||||
version: "0.2.19-nullsafety.2"
|
||||
typed_data:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: typed_data
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
version: "1.3.0-nullsafety.3"
|
||||
vector_math:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: vector_math
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.8"
|
||||
version: "2.1.0-nullsafety.3"
|
||||
watcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -290,4 +290,4 @@ packages:
|
||||
source: hosted
|
||||
version: "2.2.1"
|
||||
sdks:
|
||||
dart: ">=2.9.0-14.0.dev <3.0.0"
|
||||
dart: ">=2.10.0-110 <2.11.0"
|
||||
|
Reference in New Issue
Block a user