Pubspec Checker

DocumentationIssuesExampleLicensePub.dev

A simple Dart/Flutter package that checks the compatibility of all dependencies in the pubspec.yaml file for specified platforms. This package reads the pubspec.yaml file, fetches the package information from pub.dev, and verifies the platforms (like Android, iOS, web, macOS, Windows, and Linux) against the provided list.

✨ Features

  • Platform Compatibility Check:
    • Specify platforms (e.g., android, ios, web, etc.) to check which packages are supported.
  • Detailed Reporting:
    • List all packages with their supported platforms. Optionally show package links for more details.
  • Easy to Use:
    • Command-line arguments for quick execution and flexibility.

🚀 Getting started

Add pubspec_checker to your Flutter or Dart project:

dev_dependencies:
  pubspec_checker: ^1.0.4

Run this command:

flutter pub get

📒 Usage

Command-Line Interface (CLI) To use the package, run the following command:

dart run pubspec_checker <platforms> [options]

Parameters

  • <platforms>: The platforms to check compatibility for. Supported values are:
    • android
    • ios
    • web
    • windows
    • linux
    • macos

Options

  • -s or --show: Display the list of packages with their supported platforms.
  • -l or --links: Display the links to the package details.

📚 Examples

Check compatibility for android and ios:

dart run pubspec_checker android ios

Check compatibility for android and ios and shows package link:

dart run pubspec_checker android ios -l

Check compatibility for web:

dart run pubspec_checker web

or

dart run pubspec_checker:web

Example Output:

PS D:\Repository\pubspec_checker\example> dart run pubspec_checker windows ios
Building package executable...
Built pubspec_checker:pubspec_checker.
------- Started checking compatibility for "windows" -------
(2) Supported:
  ✅  file_picker
  ✅  connectivity_plus
(5) Not Supported:
  ❌  pusher_client
  ❌  disk_space
  ❌  open_file_plus
  ❌  sqflite_sqlcipher
  ❌  flutter_pdfview
------- Compatibility check completed for "windows" --------

💡 Additional information

If you want to use the package programmatically, here’s how you can do it:

import 'package:pubspec_checker/pubspec_checker.dart';

void main() async {
  final checker = PlatformChecker(['ios', 'android']);
  final reader = PubspecReader();

  final dependencies = reader.getDependencies();
  final results = await checker.checkPackageCompatibility(dependencies);

  for (var package in results.entries) {
    print('Package: ${package.key}, Supported Platforms: ${package.value['platforms'].join(", ")}');
  }
}

NOTE: Using package in the code, make sure you add it under pubspec dependencies not in the dev_dependencies.

Sample Output:

🐞 Contributing

Contributions are welcome! If you encounter any issues or have feature requests, please open an issue or submit a pull request on GitHub.

🎖️ License

This package is licensed under the MIT License.

Libraries

pubspec_checker
The main library file for the pubspec_checker package. This library exports all utility files required for platform checking.