flet-lottie 0.1.0__py3-none-any.whl → 0.2.0.dev36__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of flet-lottie might be problematic. Click here for more details.
- flet_lottie/__init__.py +1 -1
- flet_lottie/lottie.py +97 -198
- flet_lottie-0.2.0.dev36.dist-info/METADATA +66 -0
- flet_lottie-0.2.0.dev36.dist-info/RECORD +16 -0
- {flet_lottie-0.1.0.dist-info → flet_lottie-0.2.0.dev36.dist-info}/WHEEL +1 -1
- flet_lottie-0.2.0.dev36.dist-info/licenses/LICENSE +201 -0
- flutter/flet_lottie/CHANGELOG.md +4 -0
- flutter/flet_lottie/lib/flet_lottie.dart +1 -1
- flutter/flet_lottie/lib/src/extension.dart +16 -0
- flutter/flet_lottie/lib/src/lottie.dart +88 -63
- flutter/flet_lottie/pubspec.lock +169 -120
- flutter/flet_lottie/pubspec.yaml +8 -3
- flet_lottie-0.1.0.dist-info/METADATA +0 -41
- flet_lottie-0.1.0.dist-info/RECORD +0 -15
- flutter/flet_lottie/lib/src/create_control.dart +0 -20
- {flet_lottie-0.1.0.dist-info → flet_lottie-0.2.0.dev36.dist-info}/top_level.txt +0 -0
|
@@ -6,93 +6,118 @@ import 'package:flutter/widgets.dart';
|
|
|
6
6
|
import 'package:lottie/lottie.dart';
|
|
7
7
|
|
|
8
8
|
class LottieControl extends StatefulWidget {
|
|
9
|
-
final Control? parent;
|
|
10
9
|
final Control control;
|
|
11
|
-
final Widget? nextChild;
|
|
12
|
-
final FletControlBackend backend;
|
|
13
10
|
|
|
14
|
-
const LottieControl(
|
|
15
|
-
{super.key,
|
|
16
|
-
required this.parent,
|
|
17
|
-
required this.control,
|
|
18
|
-
required this.nextChild,
|
|
19
|
-
required this.backend});
|
|
11
|
+
const LottieControl({super.key, required this.control});
|
|
20
12
|
|
|
21
13
|
@override
|
|
22
14
|
State<LottieControl> createState() => _LottieControlState();
|
|
23
15
|
}
|
|
24
16
|
|
|
25
|
-
class _LottieControlState extends State<LottieControl>
|
|
17
|
+
class _LottieControlState extends State<LottieControl> {
|
|
26
18
|
@override
|
|
27
19
|
Widget build(BuildContext context) {
|
|
28
20
|
debugPrint(
|
|
29
21
|
"Lottie build: ${widget.control.id} (${widget.control.hashCode})");
|
|
30
22
|
|
|
31
|
-
var src = widget.control.
|
|
32
|
-
var srcBase64 = widget.control.
|
|
23
|
+
var src = widget.control.getString("src");
|
|
24
|
+
var srcBase64 = widget.control.getString("src_base64");
|
|
33
25
|
|
|
34
|
-
if (src ==
|
|
26
|
+
if (src == null && srcBase64 == null) {
|
|
35
27
|
return const ErrorControl(
|
|
36
28
|
"Lottie must have either \"src\" or \"src_base64\" specified.");
|
|
37
29
|
}
|
|
38
30
|
|
|
39
|
-
var repeat = widget.control.
|
|
40
|
-
var backgroundLoading = widget.control.
|
|
41
|
-
var reverse = widget.control.
|
|
42
|
-
var animate = widget.control.
|
|
43
|
-
var fit =
|
|
44
|
-
|
|
45
|
-
|
|
31
|
+
var repeat = widget.control.getBool("repeat", true)!;
|
|
32
|
+
var backgroundLoading = widget.control.getBool("background_loading");
|
|
33
|
+
var reverse = widget.control.getBool("reverse", false)!;
|
|
34
|
+
var animate = widget.control.getBool("animate", true)!;
|
|
35
|
+
var fit = widget.control.getBoxFit("fit");
|
|
36
|
+
var alignment = widget.control.getAlignment("alignment");
|
|
37
|
+
var filterQuality = widget.control.getFilterQuality("filter_quality");
|
|
38
|
+
var errorContent = widget.control.buildWidget("error_content");
|
|
39
|
+
var options = LottieOptions(
|
|
40
|
+
enableMergePaths: widget.control.getBool("enable_merge_paths", false)!,
|
|
41
|
+
enableApplyingOpacityToLayers:
|
|
42
|
+
widget.control.getBool("enable_layers_opacity", false)!,
|
|
43
|
+
);
|
|
44
|
+
void onError(String value) {
|
|
45
|
+
if (widget.control.getBool("on_error", false)!) {
|
|
46
|
+
widget.control.triggerEvent("error", value);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
46
49
|
|
|
47
|
-
void
|
|
48
|
-
if (widget.control.
|
|
49
|
-
widget.
|
|
50
|
+
void onLoad(LottieComposition composition) {
|
|
51
|
+
if (widget.control.getBool("on_load", false)!) {
|
|
52
|
+
widget.control.triggerEvent("load");
|
|
50
53
|
}
|
|
51
54
|
}
|
|
52
55
|
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
Widget errorBuilder(context, error, stackTrace) {
|
|
57
|
+
onError(error.toString());
|
|
58
|
+
return errorContent ??
|
|
59
|
+
ErrorControl("Error loading Lottie", description: error.toString());
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
Widget? lottie;
|
|
55
63
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
64
|
+
if (srcBase64 != null) {
|
|
65
|
+
try {
|
|
66
|
+
Uint8List bytes = base64Decode(srcBase64);
|
|
67
|
+
lottie = Lottie.memory(
|
|
68
|
+
bytes,
|
|
69
|
+
repeat: repeat,
|
|
70
|
+
reverse: reverse,
|
|
71
|
+
animate: animate,
|
|
72
|
+
alignment: alignment,
|
|
73
|
+
fit: fit,
|
|
74
|
+
filterQuality: filterQuality,
|
|
75
|
+
options: options,
|
|
76
|
+
backgroundLoading: backgroundLoading,
|
|
77
|
+
errorBuilder: errorBuilder,
|
|
78
|
+
onLoaded: onLoad,
|
|
79
|
+
onWarning: onError,
|
|
80
|
+
);
|
|
81
|
+
} catch (ex) {
|
|
82
|
+
onError(ex.toString());
|
|
83
|
+
return errorContent ??
|
|
84
|
+
ErrorControl("Error decoding src_base64",
|
|
85
|
+
description: ex.toString());
|
|
86
|
+
}
|
|
87
|
+
} else {
|
|
88
|
+
var assetSrc = widget.control.backend.getAssetSource(src!);
|
|
89
|
+
if (assetSrc.isFile) {
|
|
90
|
+
// Local File
|
|
91
|
+
lottie = Lottie.asset(assetSrc.path,
|
|
92
|
+
repeat: repeat,
|
|
93
|
+
reverse: reverse,
|
|
94
|
+
animate: animate,
|
|
95
|
+
alignment: alignment,
|
|
96
|
+
options: options,
|
|
97
|
+
fit: fit,
|
|
98
|
+
filterQuality: filterQuality,
|
|
99
|
+
backgroundLoading: backgroundLoading,
|
|
100
|
+
errorBuilder: errorBuilder,
|
|
101
|
+
onLoaded: onLoad,
|
|
102
|
+
onWarning: onError);
|
|
70
103
|
} else {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
repeat: repeat,
|
|
86
|
-
reverse: reverse,
|
|
87
|
-
animate: animate,
|
|
88
|
-
fit: fit,
|
|
89
|
-
filterQuality: filterQuality,
|
|
90
|
-
backgroundLoading: backgroundLoading,
|
|
91
|
-
onWarning: onWarning);
|
|
92
|
-
}
|
|
104
|
+
// URL
|
|
105
|
+
lottie = Lottie.network(assetSrc.path,
|
|
106
|
+
repeat: repeat,
|
|
107
|
+
reverse: reverse,
|
|
108
|
+
animate: animate,
|
|
109
|
+
alignment: alignment,
|
|
110
|
+
fit: fit,
|
|
111
|
+
options: options,
|
|
112
|
+
filterQuality: filterQuality,
|
|
113
|
+
backgroundLoading: backgroundLoading,
|
|
114
|
+
headers: widget.control.get("headers")?.cast<String, String>(),
|
|
115
|
+
errorBuilder: errorBuilder,
|
|
116
|
+
onLoaded: onLoad,
|
|
117
|
+
onWarning: onError);
|
|
93
118
|
}
|
|
119
|
+
}
|
|
94
120
|
|
|
95
|
-
|
|
96
|
-
});
|
|
121
|
+
return ConstrainedControl(control: widget.control, child: lottie);
|
|
97
122
|
}
|
|
98
123
|
}
|