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: Lottie.asset(
|
||||
assetName,
|
||||
onWarning: _logger.info,
|
||||
onWarning: (w) => _logger.info('$assetName - $w'),
|
||||
frameBuilder: (context, child, composition) {
|
||||
return AnimatedOpacity(
|
||||
opacity: composition == null ? 0 : 1,
|
||||
|
@ -14,7 +14,7 @@ packages:
|
||||
name: async
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.6.1"
|
||||
version: "2.5.0"
|
||||
boolean_selector:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -99,9 +99,11 @@ class LottieComposition {
|
||||
WarningCallback? onWarning;
|
||||
|
||||
void addWarning(String warning) {
|
||||
_warnings.add(warning);
|
||||
var isNew = _warnings.add(warning);
|
||||
if (isNew) {
|
||||
onWarning?.call(warning);
|
||||
}
|
||||
}
|
||||
|
||||
void incrementMatteOrMaskCount(int amount) {
|
||||
_maskAndMatteCount += amount;
|
||||
|
@ -436,9 +436,16 @@ class _LottieBuilderState extends State<LottieBuilder> {
|
||||
void _load() {
|
||||
var provider = widget.lottie;
|
||||
_loadingFuture = widget.lottie.load().then((composition) {
|
||||
if (mounted && widget.onLoaded != null && widget.lottie == provider) {
|
||||
composition.onWarning = widget.onWarning;
|
||||
widget.onLoaded!(composition);
|
||||
if (mounted && widget.lottie == provider) {
|
||||
var onWarning = widget.onWarning;
|
||||
composition.onWarning = onWarning;
|
||||
if (onWarning != null) {
|
||||
for (var warning in composition.warnings) {
|
||||
onWarning(warning);
|
||||
}
|
||||
}
|
||||
|
||||
widget.onLoaded?.call(composition);
|
||||
}
|
||||
|
||||
return composition;
|
||||
|
@ -84,8 +84,6 @@ class ContentModelParser {
|
||||
break;
|
||||
case 'mm':
|
||||
model = MergePathsParser.parse(reader);
|
||||
composition.addWarning('Animation contains merge paths. '
|
||||
'Merge paths must be manually enabled by settings enableMergePaths.');
|
||||
break;
|
||||
case 'rp':
|
||||
model = RepeaterParser.parse(reader, composition);
|
||||
|
Reference in New Issue
Block a user