Packages from pub.dev

Packages from pub.dev

About

  • Dependency Management: Centralized repository
  • Versioning: Semantic versioning
  • Quality Indicators: Likes, popularity, health
  • Categories: Flutter, web, server

Main Topics

  1. Finding Packages

    • Definition: Search and discovery
    • Example:
      # Popular packages:
      # http, provider, bloc, get_it
  2. Adding Dependencies

    • Definition: pubspec.yaml
    • Example:
      dependencies:
        http: ^0.13.3
        provider: ^6.0.1
  3. Version Constraints

    • Definition: Caret syntax
    • Example:
      dependencies:
        path: ^1.8.0 # 1.8.0 <= version < 2.0.0
  4. Dev Dependencies

    • Definition: Test/build only
    • Example:
      dev_dependencies:
        test: ^1.16.8
        mockito: ^5.0.0
  5. Updating Packages

    • Definition: Version resolution
    • Example:
      flutter pub upgrade
      flutter pub outdated

How to Use

  • Search: pub.dev website
  • Add: Edit pubspec.yaml
  • Install: flutter pub get
  • Update: Regularly check upgrades

How It Works

  1. Resolution: Version solving
  2. Download: Package caching
  3. Locking: pubspec.lock
  4. Integration: Build system

Example:

name: my_app
description: A sample application

dependencies:
  flutter:
    sdk: flutter
  cupertino_icons: ^1.0.2
  http: ^0.13.3

dev_dependencies:
  flutter_test:
    sdk: flutter

Conclusion

Pub.dev packages provide a vast ecosystem of reusable Dart and Flutter code. By understanding version constraints, dependency types, and update practices, developers can effectively leverage community packages while maintaining stable application builds.