Skip to content

Please support hot reload for certain assets  #5031

Closed

Description

@sma

I've a Flutter app that contains a lot of markdown files as assets and needs to display them.

Changing such a file doesn't automatically trigger a hot reload so I have to manually press the yellow lightening button to verify whether my changes to those files look good. It would improve quality of life if this could happen automatically.

Hence, it would be nice if the plugin would use the pubspec file to find all assets and then optionally also hot reload if those assets are changed. Or just add md to the list of watched files in the shouldHotReloadFor function :)

Activity

  1. added
    is enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.
    on Mar 12, 2024
  2. added this to the v3.86.0 milestone on Mar 12, 2024
  3. added
    in flutterRelates to running Flutter apps
    in editorRelates to code editing or language features
    in debuggingRelates to the debug adapter or process of running debug sessions
    on Mar 12, 2024
  4. DanTup commented on Mar 12, 2024

    @DanTup
    Member

    I think this should be opt-in because it might be unexpected if you're editing a README or something and it triggers reload (not to mention that the use case for .md is equally applicable to other assets).

  5. DanTup commented on Mar 12, 2024

    @DanTup
    Member

    I added a new setting for this:

    "dart.hotReloadPatterns": [
    	"**/*.md", // All .md files
    	"**/assets/**", // Do everything in assets
    ]
    
  6. DanTup commented on Mar 14, 2024

    @DanTup
    Member

    This fix was included in a new pre-release version. If you want to test it out without waiting for the next stable version, you can switch to the pre-release versions of the extensions in VS Code using the button shown in the screenshot below.

    Dart pre-release versions

    Please let me know if you hit any issues. Thanks!

  7. sma commented on Mar 19, 2024

    @sma
    Author

    At first, I used "assets/**" as pattern which didn't work but when I added the **/ prefix, it worked like a charm. I added the configuration as a workspace setting to my project so it gets only activated for my wiki project. Thanks.

  8. DanTup commented on Mar 19, 2024

    @DanTup
    Member

    Yeah, the pattern is matched against the full path:

    The pattern is matched against the absolute path of the file. Use **/assets/** to trigger reloading for everything in the assets directory.

    There was something odd when we didn't do it this way but I don't recall what off the top off my head (this use of globs was copied from a similar legacy setting we had for formatting).

    Glad it's working :)

  9. jacob314 commented on Apr 2, 2024

    @jacob314

    If this works well it is probably worth specifying in pubspec.yaml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in debuggingRelates to the debug adapter or process of running debug sessionsin editorRelates to code editing or language featuresin flutterRelates to running Flutter appsis enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions