Skip to content

Show dart pub add --dev for development-only packages #9502

Description

@shinriyo

Summary

Some packages are intended to be used only as development dependencies, such as code generators, linters, and testing tools.

However, the Install tab on pub.dev always generates a regular install command, for example:

dart pub add build_runner

This can mislead users into adding development-only packages to dependencies instead of dev_dependencies.

Examples

Examples of packages that are typically added as development dependencies:

  • build_runner
  • flutter_lints
  • test
  • riverpod_generator

For these packages, the recommended command would instead be:

dart pub add dev:build_runner

(or the equivalent command for the current supported syntax).

Proposal

Allow package authors to indicate that a package is intended to be installed as a development dependency.

pub.dev could then generate the appropriate install command automatically for those packages.

This would only affect the generated installation instructions and would not prevent users from installing the package as a regular dependency if they intentionally choose to do so.

Motivation

Many beginners simply copy and paste the generated command from the Install tab.

Providing the recommended command would help users follow best practices and reduce accidental misuse of development-only packages.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions