-
-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ Add package
to generated assets
#401
Conversation
@wasabeef Could you take a first look and let me know if you have some other thoughts? I haven't write tests or docs for this yet. |
@AlexV525 |
Thanks. I'm going to have a few days break and I'll be back to update this then. |
Codecov Report
@@ Coverage Diff @@
## main #401 +/- ##
==========================================
+ Coverage 98.26% 98.28% +0.01%
==========================================
Files 20 20
Lines 691 698 +7
==========================================
+ Hits 679 686 +7
Misses 12 12
|
@Deprecated('Do not use package for a package asset') | ||
String? package = package, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dart_style
formatter will produce a different result for this line.
It's a disaster when using |
README.md
Outdated
flutter_gen: | ||
assets: | ||
outputs: | ||
package_parameter_enabled: false # <- Add this line. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: package_parameter_enabled
seems quite long, surely package_parameter
would also be acceptable?
and in your example, would you set this to "true" to have the package parameter included?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
package_parameter_enabled
seems quite long, surelypackage_parameter
would also be acceptable?
The parameter is not new, so it'd be a breaking change if we use another name.
and in your example, would you set this to "true" to have the package parameter included?
Sure. Sounds good too.
@bramp Can you help with merging and publishing? |
@AlexV525 I'd be happy to review, but I'm not a maintainer of this project. I just came across this PR when I realised I needed the package name. |
cc @lcdsmao |
how is going this feature, it so useful with using modular import. |
# Conflicts: # packages/core/lib/generators/assets_generator.dart
SvgPicture svg({ | ||
Key? key, | ||
bool matchTextDirection = false, | ||
AssetBundle? bundle, | ||
String? package = 'example_resources', | ||
@Deprecated('Do not use package for a package asset') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the deprecated message, what should the developer do instead? "Do not use" doesn't tell them what to do instead.
@deprecated("Package is no longer needed as it now defaults to correct package") ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They should not use package for a package asset, which literally means not using it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah and it's @deprecated
actually.
@@ -84,7 +88,7 @@ class AssetGenImage { | |||
bool matchTextDirection = false, | |||
bool gaplessPlayback = false, | |||
bool isAntiAlias = false, | |||
String? package = 'example_resources', | |||
@deprecated String? package = package, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No deprecate message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is because of a dart_style
formatting issue and I cannot get a consist behavior when generating files with @Deprecated
, so go for the @deprecated
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah sorry you did explain that back in July. Sorry for asking again!
I just tried again locally, and dart format
does not change it when it's formatted it either:
@Deprecated("short") String? package,
or
@Deprecated("really really really really really really really really really really really long ")
String? package,
Ok, it's such a minor thing, it's not worth debugging more. But maybe off-topic, but is the dart_style
package still needed? dart format
works fine without it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but is the
dart_style
package still needed?dart format
works fine without it.
So far it looks to be required because codes are generated when running runners and produced formatted files without calling dart format
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see, dart_style is used during the generating of the code.
I noticed the version of dart_style listed in packages/core/pubspec.yaml is a year old, and the dart format being run in the GitHub actions seems a lot newer than that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed the version of dart_style listed in packages/core/pubspec.yaml is a year old, and the dart format being run in the GitHub actions seems a lot newer than that.
That's fine unless it released v3 then we'll need to manually bump it.
@@ -119,7 +123,7 @@ class AssetGenImage { | |||
|
|||
ImageProvider provider({ | |||
AssetBundle? bundle, | |||
String? package = 'example_resources', | |||
String? package = package, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing deprecate message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, thanks!
What does this change?
Add
package
and the default value ofpackage
to the generated asset class and integrated assets.Fixes #399 🎯
Type of change
Please delete options that are not relevant.
Checklist:
Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
melos run unit:test
)melos run format
to automatically apply formatting)