-
-
Notifications
You must be signed in to change notification settings - Fork 142
/
svg_integration.dart
83 lines (70 loc) · 2.22 KB
/
svg_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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import '../../settings/asset_type.dart';
import 'integration.dart';
class SvgIntegration extends Integration {
SvgIntegration(String packageParameterLiteral)
: super(packageParameterLiteral);
String get packageExpression => packageParameterLiteral.isNotEmpty
? ' = \'$packageParameterLiteral\''
: '';
@override
List<String> get requiredImports => [
'package:flutter_svg/flutter_svg.dart',
'package:flutter/services.dart',
];
@override
String get classOutput => _classDefinition;
String get _classDefinition => '''class SvgGenImage {
const SvgGenImage(this._assetName);
final String _assetName;
SvgPicture svg({
Key? key,
bool matchTextDirection = false,
AssetBundle? bundle,
String? package$packageExpression,
double? width,
double? height,
BoxFit fit = BoxFit.contain,
AlignmentGeometry alignment = Alignment.center,
bool allowDrawingOutsideViewBox = false,
WidgetBuilder? placeholderBuilder,
Color? color,
BlendMode colorBlendMode = BlendMode.srcIn,
String? semanticsLabel,
bool excludeFromSemantics = false,
Clip clipBehavior = Clip.hardEdge,
bool cacheColorFilter = false,
SvgTheme? theme,
}) {
return SvgPicture.asset(
_assetName,
key: key,
matchTextDirection: matchTextDirection,
bundle: bundle,
package: package,
width: width,
height: height,
fit: fit,
alignment: alignment,
allowDrawingOutsideViewBox: allowDrawingOutsideViewBox,
placeholderBuilder: placeholderBuilder,
color: color,
colorBlendMode: colorBlendMode,
semanticsLabel: semanticsLabel,
excludeFromSemantics: excludeFromSemantics,
clipBehavior: clipBehavior,
cacheColorFilter: cacheColorFilter,
theme: theme,
);
}
String get path => _assetName;
String get keyName => ${packageParameterLiteral.isEmpty ? '_assetName' : '\'packages/$packageParameterLiteral/\$_assetName\''};
}''';
@override
String get className => 'SvgGenImage';
@override
String classInstantiate(String path) => 'SvgGenImage(\'$path\')';
@override
bool isSupport(AssetType type) => type.mime == 'image/svg+xml';
@override
bool get isConstConstructor => true;
}