flet-rive 0.1.0__py3-none-any.whl → 0.2.0.dev30__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-rive might be problematic. Click here for more details.

@@ -3,78 +3,73 @@ import 'package:flutter/widgets.dart';
3
3
  import 'package:rive/rive.dart';
4
4
 
5
5
  class RiveControl extends StatefulWidget {
6
- final Control? parent;
7
6
  final Control control;
8
- final List<Control> children;
9
- final bool parentDisabled;
10
- final bool? parentAdaptive;
11
- final FletControlBackend backend;
12
7
 
13
- const RiveControl(
14
- {super.key,
15
- required this.parent,
16
- required this.control,
17
- required this.children,
18
- required this.parentDisabled,
19
- required this.parentAdaptive,
20
- required this.backend});
8
+ const RiveControl({super.key, required this.control});
21
9
 
22
10
  @override
23
11
  State<RiveControl> createState() => _RiveControlState();
24
12
  }
25
13
 
26
- class _RiveControlState extends State<RiveControl> with FletStoreMixin {
14
+ class _RiveControlState extends State<RiveControl> {
27
15
  @override
28
16
  Widget build(BuildContext context) {
29
17
  debugPrint("Rive build: ${widget.control.id} (${widget.control.hashCode})");
30
- bool disabled = widget.control.isDisabled || widget.parentDisabled;
31
- Widget? placeholder;
32
-
33
- var src = widget.control.attrString("src", "")!;
34
- if (src == "") {
18
+ var src = widget.control.getString("src");
19
+ if (src == null) {
35
20
  return const ErrorControl("Rive must have \"src\" specified.");
36
21
  }
37
22
 
38
- var artBoard = widget.control.attrString("artBoard");
39
- var antiAliasing = widget.control.attrBool("enableAntiAliasing", true)!;
40
- var useArtBoardSize = widget.control.attrBool("useArtBoardSize", false)!;
41
- var fit = parseBoxFit(widget.control.attrString("fit"));
42
- var alignment = parseAlignment(widget.control, "alignment");
43
- var ctrls = widget.children.where((c) => c.isVisible);
44
- if (ctrls.isNotEmpty) {
45
- placeholder = createControl(widget.control, ctrls.first.id, disabled);
46
- }
23
+ var artBoard = widget.control.getString("art_board");
24
+ var antiAliasing = widget.control.getBool("enable_anti_aliasing", true)!;
25
+ var useArtBoardSize = widget.control.getBool("use_art_board_size", false)!;
26
+ var fit = widget.control.getBoxFit("fit");
27
+ var alignment = widget.control.getAlignment("alignment");
28
+ var placeholder = widget.control.buildWidget("placeholder");
29
+ var speedMultiplier = widget.control.getDouble("speed_multiplier", 1)!;
30
+ var animations = widget.control.get<List<String>>("animations", const [])!;
31
+ var stateMachines =
32
+ widget.control.get<List<String>>("state_machines", const [])!;
33
+ var headers = widget.control.get("headers")?.cast<String, String>();
34
+ var clipRect = widget.control.getRect("clip_rect");
47
35
 
48
- return withPageArgs((context, pageArgs) {
49
- Widget? rive;
36
+ Widget? rive;
50
37
 
51
- var assetSrc = getAssetSrc(src, pageArgs.pageUri!, pageArgs.assetsDir);
52
- if (assetSrc.isFile) {
53
- // Local File
54
- rive = RiveAnimation.file(
55
- assetSrc.path,
56
- artboard: artBoard,
57
- fit: fit,
58
- antialiasing: antiAliasing,
59
- useArtboardSize: useArtBoardSize,
60
- alignment: alignment,
61
- placeHolder: placeholder,
62
- );
63
- } else {
64
- // URL
65
- rive = RiveAnimation.network(
66
- assetSrc.path,
67
- fit: fit,
68
- artboard: artBoard,
69
- alignment: alignment,
70
- antialiasing: antiAliasing,
71
- useArtboardSize: useArtBoardSize,
72
- placeHolder: placeholder,
73
- // onInit: _onInit,
74
- );
75
- }
38
+ var assetSrc = widget.control.backend.getAssetSource(src);
39
+ if (assetSrc.isFile) {
40
+ // Local File
41
+ rive = RiveAnimation.file(
42
+ assetSrc.path,
43
+ artboard: artBoard,
44
+ fit: fit,
45
+ antialiasing: antiAliasing,
46
+ useArtboardSize: useArtBoardSize,
47
+ alignment: alignment,
48
+ placeHolder: placeholder,
49
+ speedMultiplier: speedMultiplier,
50
+ animations: animations,
51
+ stateMachines: stateMachines,
52
+ clipRect: clipRect,
53
+ );
54
+ } else {
55
+ // URL
56
+ rive = RiveAnimation.network(
57
+ assetSrc.path,
58
+ fit: fit,
59
+ artboard: artBoard,
60
+ alignment: alignment,
61
+ antialiasing: antiAliasing,
62
+ useArtboardSize: useArtBoardSize,
63
+ placeHolder: placeholder,
64
+ speedMultiplier: speedMultiplier,
65
+ animations: animations,
66
+ stateMachines: stateMachines,
67
+ headers: headers,
68
+ clipRect: clipRect,
69
+ // onInit: _onInit,
70
+ );
71
+ }
76
72
 
77
- return constrainedControl(context, rive, widget.parent, widget.control);
78
- });
73
+ return ConstrainedControl(control: widget.control, child: rive);
79
74
  }
80
75
  }