Search packages, repositories and app categories

Package detailsv2.2.0

pubspec_lock_parse

Simple package for parsing pubspec.lock files with a type-safe API and rich error reporting.

AndroidiOSWebmacOSWindowsLinux
30-day downloads
215K
Likes
2
Pub points
140

Install package

flutter pub add pubspec_lock_parse

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

A type-safe Dart package designed to parse pubspec.lock files with clear, detailed error reporting. It provides a structured API for reading and analyzing dependency information from Flutter and Dart projects, making it easier to programmatically inspect package versions and dependencies. Ideal for tooling that requires reliable access to lock file data without manual string parsing.

Use cases

  • Parsing dependency versions in CI/CD pipelines
  • Validating project dependencies
  • Building custom dependency analysis tools
  • Automating version checks in development workflows

Key features

  • Type-safe API
  • Comprehensive error messages
  • Supports all major platforms
  • Easy integration via Flutter pub
  • Accurate lock file parsing

Suitable for

  • Tool developers
  • CI/CD script authors
  • Dependency management utilities
  • Dart/Flutter CLI extensions

Considerations

  • Requires valid pubspec.lock format
  • Not intended for modifying lock files
  • Limited to read-only operations
  • Depends on correct file structure

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

Dart pub package

Supports parsing pubspec.lock files with robust error reporting

Designed around the pubspec_parse package, and mirrors its implementation and interface

Usage

import 'dart:io';
import 'package:pubspec_lock_parse/pubspec_lock_parse.dart';

void main() {
    final lockStr = File('path/to/pubspec.lock').readAsStringSync();
    final lockfile = PubspecLock.parse(lockStr);
}

You can find more about the PubspecLock object in the documentation here

toJson() methods

pubspec_lock_parse includes .toJson() methods on each object to allow for easy re-generation/mutation of pubspec files

This can be combined with yaml_writer to re-generate yaml output

void main() {
    final pubspec = PubspecLock(
        packages: {
            'somePackage': Package(
                dependency: 'transitive',
                description: PathPackageDescription(
                    path: '../somePackage',
                    relative: true,
                )
            )
        },
        sdks: {
            'dart': VersionConstraint.parse(">=2.17.0 <3.0.0"),
        }
    );

    final jsonPubspec = pubspec.toJson(); // outputs Map<String, dynamic>
    final yamlPubspec = YamlWriter().write(jsonPubspec); // outputs String
}

toJson can also be run on any individual object

// outputs: { path: '../somePackage', relative: true }
print(PathPackageDescription(
    path: '../somePackage',
    relative: true,
).toJson());

Categories

Dependencies

Dependency list 4 items

Source repository

Projects using this package

No data available yet.

Rankings