mirror of
https://github.com/xvrh/lottie-flutter.git
synced 2025-08-06 16:39:36 +08:00
Fix onWarning callback (#156)
This commit is contained in:
@ -42,7 +42,7 @@ class App extends StatelessWidget {
|
|||||||
child: _Item(
|
child: _Item(
|
||||||
child: Lottie.asset(
|
child: Lottie.asset(
|
||||||
assetName,
|
assetName,
|
||||||
onWarning: _logger.info,
|
onWarning: (w) => _logger.info('$assetName - $w'),
|
||||||
frameBuilder: (context, child, composition) {
|
frameBuilder: (context, child, composition) {
|
||||||
return AnimatedOpacity(
|
return AnimatedOpacity(
|
||||||
opacity: composition == null ? 0 : 1,
|
opacity: composition == null ? 0 : 1,
|
||||||
|
@ -14,7 +14,7 @@ packages:
|
|||||||
name: async
|
name: async
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.6.1"
|
version: "2.5.0"
|
||||||
boolean_selector:
|
boolean_selector:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -99,8 +99,10 @@ class LottieComposition {
|
|||||||
WarningCallback? onWarning;
|
WarningCallback? onWarning;
|
||||||
|
|
||||||
void addWarning(String warning) {
|
void addWarning(String warning) {
|
||||||
_warnings.add(warning);
|
var isNew = _warnings.add(warning);
|
||||||
onWarning?.call(warning);
|
if (isNew) {
|
||||||
|
onWarning?.call(warning);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void incrementMatteOrMaskCount(int amount) {
|
void incrementMatteOrMaskCount(int amount) {
|
||||||
|
@ -436,9 +436,16 @@ class _LottieBuilderState extends State<LottieBuilder> {
|
|||||||
void _load() {
|
void _load() {
|
||||||
var provider = widget.lottie;
|
var provider = widget.lottie;
|
||||||
_loadingFuture = widget.lottie.load().then((composition) {
|
_loadingFuture = widget.lottie.load().then((composition) {
|
||||||
if (mounted && widget.onLoaded != null && widget.lottie == provider) {
|
if (mounted && widget.lottie == provider) {
|
||||||
composition.onWarning = widget.onWarning;
|
var onWarning = widget.onWarning;
|
||||||
widget.onLoaded!(composition);
|
composition.onWarning = onWarning;
|
||||||
|
if (onWarning != null) {
|
||||||
|
for (var warning in composition.warnings) {
|
||||||
|
onWarning(warning);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
widget.onLoaded?.call(composition);
|
||||||
}
|
}
|
||||||
|
|
||||||
return composition;
|
return composition;
|
||||||
|
@ -84,8 +84,6 @@ class ContentModelParser {
|
|||||||
break;
|
break;
|
||||||
case 'mm':
|
case 'mm':
|
||||||
model = MergePathsParser.parse(reader);
|
model = MergePathsParser.parse(reader);
|
||||||
composition.addWarning('Animation contains merge paths. '
|
|
||||||
'Merge paths must be manually enabled by settings enableMergePaths.');
|
|
||||||
break;
|
break;
|
||||||
case 'rp':
|
case 'rp':
|
||||||
model = RepeaterParser.parse(reader, composition);
|
model = RepeaterParser.parse(reader, composition);
|
||||||
|
Reference in New Issue
Block a user