Flutter University
  • πŸ‘‹Welcome to Flutter University
  • Learn Flutter
    • πŸš—Basics
      • 🧺Dart Basics
      • πŸš›Setup & Installation
      • 🐣Hello Flutter
      • πŸŒ‰Widgets
      • ⛸️Basic State Management
      • πŸ‡ΎπŸ‡ΉBasic Layout and Styling
      • 🐝Basic Interactivity
      • πŸ›£οΈNavigation
      • πŸͺ„Working with Assets
    • πŸš…Intermediate
      • 🎯Deeper into Dart
      • ⭐More on State Management
      • πŸ“ƒForm Handling
      • πŸ—ΌNetworking
      • πŸŽ‡Persistence
      • πŸ§™β€β™‚οΈAnimations
      • πŸ§ͺTesting
      • πŸ“¦Package Management
    • ✈️Professional
      • πŸŽ“Advanced Animations
      • 🎨Custom Painters
      • 🐼Continuous Integration/Continuous Deployment (CI/CD)
      • 🎭Performance Profiling
      • πŸ”¬Native Integrations
      • 🌍Accessibility and Localization
      • 🀘Understanding Design Patterns
      • πŸ“šFlutter Architecture
        • The Layer Model
        • Reactive User Interfaces
        • Flutter Widgets
        • The Rendering Process
        • Platform Embedders Overview
        • Integrating with Other Code
        • Support for the Web
  • Tutorials
    • 🌈UI
      • 🏚️Clubhouse Clone
      • πŸ”‰Netflix Clone
    • βš”οΈFull Stack
    • ⛓️Blockchain
    • πŸ€–AI/ML
  • Miscellaneous
    • πŸ–₯️100 Days of Flutter
    • 🎨Join Community
Powered by GitBook
On this page
  1. Learn Flutter
  2. πŸš…Intermediate

πŸ“¦Package Management

Last updated 1 year ago

Was this helpful?

CtrlK
  • 1. Adding Dependencies πŸ”—
  • 2. Updating Dependencies πŸ”„
  • 3. Removing Dependencies πŸ—‘οΈ
  • 4. Creating a Package πŸ“¦
  • 5. Publishing a Package πŸš€
  • Assignments πŸ“

Was this helpful?

Package management is crucial for managing dependencies and sharing code in a modular and reusable way. In Flutter, package management is facilitated through the use of the pubspec.yaml file, where you can specify the dependencies for your project.

1. Adding Dependencies πŸ”—

To add a new package to your Flutter project, you need to specify it in the pubspec.yaml file under the dependencies section.

Here, we've added the http package to our project.

2. Updating Dependencies πŸ”„

To update the packages to their latest versions, you can use the following command:

3. Removing Dependencies πŸ—‘οΈ

To remove a package, simply delete its entry from the pubspec.yaml file and run:

4. Creating a Package πŸ“¦

You can create your own package for sharing code. Use the following command to create a new package:

5. Publishing a Package πŸš€

To publish your package to pub.dev, follow the publishing guidelines and use the following command:

Assignments πŸ“

This way, you have a simple Flutter app demonstrating how to manage packages and use them in your project.

dependencies:
  flutter:
    sdk: flutter
  http: ^1.1.0
flutter create --template=package my_package
flutter pub publish
flutter pub upgrade
flutter pub get