Skip to content

Asset variant detection should only work on directory names that are parse-able by the framework (2x, 3x) #69388

Description

@AlexV525

Steps to Reproduce

Can repro from 1.17 to 1.23 master.

Run https://github.com/AlexV525/flutter_test_app (test-assets-conflict-page) for repro demo with master.

  1. Add two assets with same name, but not the same path. (e.g. assets/a.png and assets/b/a.png)
  2. Display those images in Flutter App.

image

Expected results: Display two different pictures/assets.

Actual results: Displayed same pictures/assets, which is the deeper one.

[✓] Flutter (Channel update-length-limiting-formatter, 1.23.0-19.0.pre.78, on Mac OS X 10.15.7 19H2 darwin-x64, locale zh-Hans-CN)

Activity

  1. yash1200 commented on Oct 30, 2020

    @yash1200
    Contributor

    Changing your assets list to this :

    final List<String> assets = <String>[
      'placeholder.png',
      'something/placeholder.png',
    ];
    

    and pubspec.yaml to this :

    flutter:
      uses-material-design: true
      assets:
        - assets/
    

    These changes fixed your issue.

  2. AlexV525 commented on Oct 30, 2020

    @AlexV525
    MemberAuthor

    @yash1200 That's weird. Since when we could use undeclared assets? Doc ref:https://flutter.dev/docs/development/ui/assets-and-images#specifying-assets

    And why an asset without full path can be used?

  3. yash1200 commented on Oct 30, 2020

    @yash1200
    Contributor

    I just experimented and it worked with this.
    Here's a screenshot:

    Screenshot_2020-10-30_16-30-22

  4. added
    a: assetsPackaging, accessing, or using assets
    frameworkflutter/packages/flutter repository. See also f: labels.
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    on Oct 30, 2020
  5. pedromassangocode commented on Oct 30, 2020

    @pedromassangocode

    I was able to reproduce however not sure if the implementation is the correct one.

  6. AlexV525 commented on Oct 30, 2020

    @AlexV525
    MemberAuthor

    I just experimented and it worked with this.

    Thanks for the quick clarify! So there must be something broken with assets loading.

  7. AlexV525 commented on Oct 30, 2020

    @AlexV525
    MemberAuthor
  8. pedromassangocode commented on Oct 30, 2020

    @pedromassangocode

    Maybe P3 since this is not blocking any customer?
    Feel free to increase the priority if necessary.

  9. added
    P1High-priority issues at the top of the work list
    and removed on Oct 30, 2020
  10. jonahwilliams commented on Oct 30, 2020

    @jonahwilliams
    Contributor

    This is mostly an intention feature - asset variants. The idea is that you can automatically pick up multiple resolutions of the same image and have the framework select them at runtime.

    a.png
    2x/a.png
    3x/a.png
    

    Of course, it is not actually restricted to 2x, 3x as you've discovered here....

  11. added
    P2Important issues not at the top of the work list
    and removed
    P1High-priority issues at the top of the work list
    on Oct 30, 2020
  12. AlexV525 commented on Oct 30, 2020

    @AlexV525
    MemberAuthor

    Of course, it is not actually restricted to 2x, 3x as you've discovered here....

    When it comes to production cases, assets like the demo in my test app, such as separate placeholder can cause confusing behaviors.

    And what about the solution that @yash1200 suggested?

  13. jonahwilliams commented on Oct 30, 2020

    @jonahwilliams
    Contributor

    I think the right fix would to restrict the asset variant code to strings that the framework can parse

  14. added
    toolAffects the "flutter" command-line tool. See also t: labels.
    and removed
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Oct 30, 2020
  15. changed the title [-]Wrong display when using same name but not the same path assets[/-] [+]Asset variant detection should only work on directory names that are parse-able by the framework (2x, 3x)[/+] on Oct 30, 2020
  16. moved this to Good starter bugs/improvements in go/flutter-tools-project (deprecated)on Jul 11, 2022
  17. christopherfujino commented on Aug 1, 2022

    @christopherfujino
    Contributor
  18. jonahwilliams commented on Aug 10, 2022

    @jonahwilliams
    Contributor

    I think this one might be an interesting first issue for @andrewkolos , if you haven't already looked at it @eliasyishak .

  19. github-actions commented on Oct 11, 2022

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  20. locked as resolved and limited conversation to collaborators on Oct 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work lista: assetsPackaging, accessing, or using assetsfound in release: 1.23Found to occur in 1.23has reproducible stepsThe issue has been confirmed reproducible and is ready to work ontoolAffects the "flutter" command-line tool. See also t: labels.

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions