Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions examples/example_resources/lib/gen/assets.gen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ class AssetGenImage {
bool matchTextDirection = false,
bool gaplessPlayback = false,
bool isAntiAlias = false,
@deprecated String? package = package,
@Deprecated('Do not specify package for a generated library asset')
String? package = package,
FilterQuality filterQuality = FilterQuality.low,
int? cacheWidth,
int? cacheHeight,
Expand Down Expand Up @@ -148,7 +149,7 @@ class SvgGenImage {
Key? key,
bool matchTextDirection = false,
AssetBundle? bundle,
@Deprecated('Do not use package for a package asset')
@Deprecated('Do not specify package for a generated library asset')
String? package = package,
double? width,
double? height,
Expand Down Expand Up @@ -300,7 +301,7 @@ class LottieGenImage {
double? height,
BoxFit? fit,
AlignmentGeometry? alignment,
@Deprecated('Do not use package for a package asset')
@Deprecated('Do not specify package for a generated library asset')
String? package = package,
bool? addRepaintBoundary,
FilterQuality? filterQuality,
Expand Down
4 changes: 3 additions & 1 deletion packages/core/lib/generators/assets_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,8 @@ ${isPackage ? "\n static const String package = '$packageName';" : ''}
bool matchTextDirection = false,
bool gaplessPlayback = false,
bool isAntiAlias = false,
${isPackage ? '@deprecated ' : ''}String? package$packageParameter,
${isPackage ? deprecationMessagePackage : ''}
String? package$packageParameter,
FilterQuality filterQuality = FilterQuality.low,
int? cacheWidth,
int? cacheHeight,
Expand Down Expand Up @@ -606,6 +607,7 @@ ${isPackage ? "\n static const String package = '$packageName';" : ''}

ImageProvider provider({
AssetBundle? bundle,
${isPackage ? deprecationMessagePackage : ''}
String? package$packageParameter,
}) {
return AssetImage(
Expand Down
5 changes: 5 additions & 0 deletions packages/core/lib/generators/integrations/integration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,8 @@ abstract class Integration {

bool get isConstConstructor;
}

/// The deprecation message for the package argument
/// if the asset is a library asset.
const String deprecationMessagePackage =
"@Deprecated('Do not specify package for a generated library asset')";
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ ${isPackage ? "\n static const String package = '$packageParameterLiteral';" :
double? height,
BoxFit? fit,
AlignmentGeometry? alignment,
${isPackage ? '@deprecated ' : ''}String? package$packageExpression,
${isPackage ? deprecationMessagePackage : ''}
String? package$packageExpression,
bool? addRepaintBoundary,
FilterQuality? filterQuality,
void Function(String)? onWarning,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ class SvgIntegration extends Integration {
const SvgGenImage(this._assetName);

final String _assetName;
${isPackage ? "\n static const String package = '$packageParameterLiteral';" : ''}

${isPackage ? "static const String package = '$packageParameterLiteral';" : ''}

SvgPicture svg({
Key? key,
bool matchTextDirection = false,
AssetBundle? bundle,
${isPackage ? '@deprecated ' : ''}String? package$packageExpression,
${isPackage ? deprecationMessagePackage : ''}
String? package$packageExpression,
double? width,
double? height,
BoxFit fit = BoxFit.contain,
Expand Down
8 changes: 7 additions & 1 deletion packages/core/test/assets_gen_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,13 @@ void main() {
expect(content, contains("static const String package = 'test';"));
expect(
content,
contains('@deprecated String? package = package,'),
contains(
"@Deprecated('Do not specify package for a generated library asset')",
),
);
expect(
content,
contains('String? package = package,'),
);
});

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.