Skip to content

Feature Request: Allow including additional license files in pubspec.yaml (similar to Flutter licenses field) #4762

@GiancarloCante

Description

@GiancarloCante

Problem

Some Dart packages include third-party code, fonts, icons, or other assets that have their own licenses.

The root LICENSE file of a package typically covers only the package itself. It usually does not explicitly list or separate third-party attributions.

Currently, there is no standard way in pubspec.yaml for a package to declare additional license files for bundled third-party components.

This creates several issues:

  • Tools cannot reliably discover third-party license files.
  • Downstream applications must manually search packages for extra notices.
  • Developers often append third-party licenses to the main LICENSE file, which makes automated SPDX detection (e.g., pana) more difficult.

Prior Art (Flutter)

Flutter already introduced a licenses field under the flutter: section of pubspec.yaml:

Flutter documentation:
https://docs.flutter.dev/tools/pubspec#licenses

Related discussion:
flutter/flutter#73363

Implementation:
flutter/flutter#73430

Flutter added this because packages may bundle third-party assets that require separate attribution, and those licenses need to be programmatically accessible for tools like LicenseRegistry.

However, this solution is Flutter-specific and not available to pure Dart packages.


Proposed Solution

Add a top-level licenses field to pubspec.yaml for all Dart packages.

Example:

name: my_package
version: 1.0.0

licenses:
  - THIRD_PARTY_LICENSES
  - assets/icons/LICENSE.txt
  - lib/src/third_party/algorithm_notice.txt

This field would:

  • Accept file paths relative to the package root.
  • Declare additional license texts bundled in the package.
  • Allow tools to programmatically collect all license attributions.

Benefits

1. Ecosystem consistency

Removes the current Flutter vs. pure Dart split in license handling.

2. Tooling support

Enables tools to aggregate licenses across a dependency tree.

3. Legal compliance

Makes it easier for downstream applications to remain compliant with third-party licenses included within dependencies.

4. Clean separation

Keeps the main LICENSE file as the license of the package itself, while additional third-party notices are clearly declared and discoverable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions