Skip to content

Switch tasks from "dart pub run" and "flutter pub run" to "dart run", setting FLUTTER_ROOT if appropriate #5874

Closed

Description

@CaLouro

Is your feature request related to a problem? Please describe.
There is no immediate problem but is related to a deprecation. Since flutter pub run was deprecated in favor of dart run, the built in task command in the extension should be updated to use dart run.

Describe the solution you'd like
Update all following build tasks to use dart run instead

  • flutter: flutter pub run build_runner build
  • flutter: flutter pub run build_runner watch
  • flutter: flutter pub run build_runner serve

Describe alternatives you've considered
No other alternatives considered.

Additional context
Output from running flutter: flutter pub run build_runner build:

Image

Activity

  1. added
    is enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.
    in flutterRelates to running Flutter apps
    on Jan 13, 2026
  2. added this to the v3.128.0 milestone on Jan 13, 2026
  3. DanTup commented on Jan 13, 2026

    @DanTup
    Member

    Since flutter pub run was deprecated in favor of dart run

    Do you have any more info about this? I couldn't find anything about it (and I see very recent Flutter PRs changing from dart pub run to flutter pub run), but I found some comments in dart-lang/build#3665 (comment) from @jakemac53 saying:

    On flutter projects you need to run using the flutter SDK, so flutter pub run build_runner build

    (and that the warning may be a bug)

    My guess is that the message "Deprecated. User dart run instead" is intended to mean "don't include pub in the command", however it's not correctly detecting that you ran via flutter and not dart.

    So I think the correct fix here is to change flutter pub run ... to just flutter run .... @sigurdm I presume this message comes from pub - does this seem accurate?

  4. added
    awaiting infoRequires more information from the customer to progress
    on Jan 13, 2026
  5. sigurdm commented on Jan 13, 2026

    @sigurdm

    The message comes from pub. pub run is deprecated. Both in the shape of flutter pub run and dart pub run.

    The intended replacement is dart run. If you need the flutter sdk, use FLUTTER_ROOT/bin/dart run that should work.

  6. sigurdm commented on Jan 13, 2026

    @sigurdm

    flutter run is intended for running a flutter app on a device, that is something completely different.

  7. DanTup commented on Jan 13, 2026

    @DanTup
    Member

    flutter run is intended for running a flutter app

    Whoops, of course!

    The intended replacement is dart run. If you need the flutter sdk, use FLUTTER_ROOT/bin/dart run that should work.

    Got it! From what SDK versions should we do this? (I failed to find anything in release notes for either SDK about when that became the preferred way, and I don't want to try and use it for older SDKs if it might not work).

    Thanks!

  8. DanTup commented on Jan 13, 2026

    @DanTup
    Member

    FLUTTER_ROOT/bin/dart run

    Also - does this have to be the Dart wrapped script, and not dart from inside the nested SDK?

    I ask, because Dart-Code never uses the dart wrapper script currently... shell scripts on Windows some issues (termination/signals not always being passed on) and generally any code written against dart we want to be the same for either SDK.

  9. sigurdm commented on Jan 13, 2026

    @sigurdm

    Also - does this have to be the Dart wrapped script, and not dart from inside the nested SDK?

    If the FLUTTER_ROOT is set, it should work

  10. DanTup commented on Jan 13, 2026

    @DanTup
    Member

    Great, thanks!

  11. removed
    awaiting infoRequires more information from the customer to progress
    on Jan 13, 2026
  12. sigurdm commented on Jan 13, 2026

    @sigurdm

    Got it! From what SDK versions should we do this?

    Good question, I only have vague memories of when we did this - it seems to be https://dart-review.googlesource.com/c/sdk/+/168347 from 2020. I think that means from dart 2.12.0 and onwards.

  13. sigurdm commented on Jan 13, 2026

    @sigurdm

    But any later version might be fine - as we have not removed pub run yet.

  14. CaLouro commented on Jan 17, 2026

    @CaLouro
    Author

    Is there anything else that I can help you both with? You both seem to know much more than me at this point.

  15. changed the title [-]Update tasks `flutter: flutter pub run build_runner` to use `dart run`[/-] [+]Switch tasks from "dart pub run" and "flutter pub run" to "dart run", setting FLUTTER_ROOT if appropriate[/+] on Jan 20, 2026
  16. added
    in tasksRelates to VS Code tasks, such as those provided by Task Providers
    and removed
    in flutterRelates to running Flutter apps
    on Jan 20, 2026
  17. DanTup commented on Jan 26, 2026

    @DanTup
    Member

    @sigurdm thanks! We only support SDKs newer than that now, so don't need to handle falling back :)

    @CaLouro I've changed this over. The changes are in the latest pre-release extension if you want to try them out now, otherwise they'll ship in a normal extension update probably at the end of this week or start of next week.

    Dart pre-release versions

    Thanks!

  18. CaLouro commented on Jan 26, 2026

    @CaLouro
    Author

    Thank you, @DanTup!

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 tasksRelates to VS Code tasks, such as those provided by Task Providersis 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