Skip to content

Commit 44d743d

Browse files
authored
✨ Add package to generated assets, pt.2 (#439)
## What does this change? Further updates to #401. ## Type of change - [x] Bug fix (non-breaking change which fixes an issue)
1 parent 76bd39e commit 44d743d

File tree

7 files changed

+30
-10
lines changed

7 files changed

+30
-10
lines changed

examples/example_resources/lib/gen/assets.gen.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ class AssetGenImage {
8888
bool matchTextDirection = false,
8989
bool gaplessPlayback = false,
9090
bool isAntiAlias = false,
91-
@deprecated String? package = package,
91+
@Deprecated('Do not specify package for a generated library asset')
92+
String? package = package,
9293
FilterQuality filterQuality = FilterQuality.low,
9394
int? cacheWidth,
9495
int? cacheHeight,
@@ -148,7 +149,7 @@ class SvgGenImage {
148149
Key? key,
149150
bool matchTextDirection = false,
150151
AssetBundle? bundle,
151-
@Deprecated('Do not use package for a package asset')
152+
@Deprecated('Do not specify package for a generated library asset')
152153
String? package = package,
153154
double? width,
154155
double? height,
@@ -300,7 +301,7 @@ class LottieGenImage {
300301
double? height,
301302
BoxFit? fit,
302303
AlignmentGeometry? alignment,
303-
@Deprecated('Do not use package for a package asset')
304+
@Deprecated('Do not specify package for a generated library asset')
304305
String? package = package,
305306
bool? addRepaintBoundary,
306307
FilterQuality? filterQuality,

packages/core/lib/generators/assets_generator.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,8 @@ ${isPackage ? "\n static const String package = '$packageName';" : ''}
571571
bool matchTextDirection = false,
572572
bool gaplessPlayback = false,
573573
bool isAntiAlias = false,
574-
${isPackage ? '@deprecated ' : ''}String? package$packageParameter,
574+
${isPackage ? deprecationMessagePackage : ''}
575+
String? package$packageParameter,
575576
FilterQuality filterQuality = FilterQuality.low,
576577
int? cacheWidth,
577578
int? cacheHeight,
@@ -606,6 +607,7 @@ ${isPackage ? "\n static const String package = '$packageName';" : ''}
606607
607608
ImageProvider provider({
608609
AssetBundle? bundle,
610+
${isPackage ? deprecationMessagePackage : ''}
609611
String? package$packageParameter,
610612
}) {
611613
return AssetImage(

packages/core/lib/generators/integrations/integration.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,8 @@ abstract class Integration {
2020

2121
bool get isConstConstructor;
2222
}
23+
24+
/// The deprecation message for the package argument
25+
/// if the asset is a library asset.
26+
const String deprecationMessagePackage =
27+
"@Deprecated('Do not specify package for a generated library asset')";

packages/core/lib/generators/integrations/lottie_integration.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ ${isPackage ? "\n static const String package = '$packageParameterLiteral';" :
5555
double? height,
5656
BoxFit? fit,
5757
AlignmentGeometry? alignment,
58-
${isPackage ? '@deprecated ' : ''}String? package$packageExpression,
58+
${isPackage ? deprecationMessagePackage : ''}
59+
String? package$packageExpression,
5960
bool? addRepaintBoundary,
6061
FilterQuality? filterQuality,
6162
void Function(String)? onWarning,

packages/core/lib/generators/integrations/svg_integration.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ class SvgIntegration extends Integration {
2020
const SvgGenImage(this._assetName);
2121
2222
final String _assetName;
23-
${isPackage ? "\n static const String package = '$packageParameterLiteral';" : ''}
23+
24+
${isPackage ? "static const String package = '$packageParameterLiteral';" : ''}
2425
2526
SvgPicture svg({
2627
Key? key,
2728
bool matchTextDirection = false,
2829
AssetBundle? bundle,
29-
${isPackage ? '@deprecated ' : ''}String? package$packageExpression,
30+
${isPackage ? deprecationMessagePackage : ''}
31+
String? package$packageExpression,
3032
double? width,
3133
double? height,
3234
BoxFit fit = BoxFit.contain,

packages/core/test/assets_gen_test.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,13 @@ void main() {
7979
expect(content, contains("static const String package = 'test';"));
8080
expect(
8181
content,
82-
contains('@deprecated String? package = package,'),
82+
contains(
83+
"@Deprecated('Do not specify package for a generated library asset')",
84+
),
85+
);
86+
expect(
87+
content,
88+
contains('String? package = package,'),
8389
);
8490
});
8591

packages/core/test_resources/actual_data/assets_package_parameter.gen.dart

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)