-
-
Notifications
You must be signed in to change notification settings - Fork 142
/
rive_integration.dart
64 lines (52 loc) · 1.59 KB
/
rive_integration.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import '../../settings/asset_type.dart';
import 'integration.dart';
class RiveIntegration extends Integration {
RiveIntegration(String packageParameterLiteral)
: super(packageParameterLiteral);
String? get packageExpression => packageParameterLiteral.isNotEmpty
? 'packages/$packageParameterLiteral/'
: null;
@override
List<String> get requiredImports => [
'package:rive/rive.dart',
];
@override
String get classOutput => _classDefinition;
String get _classDefinition => '''class RiveGenImage {
const RiveGenImage(this._assetName);
final String _assetName;
RiveAnimation rive({
String? artboard,
List<String> animations = const [],
List<String> stateMachines = const [],
BoxFit? fit,
Alignment? alignment,
Widget? placeHolder,
bool antialiasing = true,
List<RiveAnimationController> controllers = const [],
OnInitCallback? onInit,
}) {
return RiveAnimation.asset(
${packageExpression == null ? '_assetName' : '\'$packageExpression\$_assetName\''},
artboard: artboard,
animations: animations,
stateMachines: stateMachines,
fit: fit,
alignment: alignment,
placeHolder: placeHolder,
antialiasing: antialiasing,
controllers: controllers,
onInit: onInit,
);
}
String get path => _assetName;
}''';
@override
String get className => 'RiveGenImage';
@override
String classInstantiate(String path) => 'RiveGenImage(\'$path\')';
@override
bool isSupport(AssetType type) => type.extension == '.riv';
@override
bool get isConstConstructor => true;
}