Add


πŸ“ Description

The add command allows you to easily add new packages to your Flutter project's pubspec.yaml. It provides an interactive way to search, select, and install packages from pub.dev with proper dependency management.


βš™οΈ Usage

gexd add [package_name] [options]
gexd add [package_name] [version] [options]

πŸ“‹ Basic Examples:

# Add a package interactively
gexd add

# Add a specific package
gexd add http

# Add a package with specific version
gexd add http ^1.1.0

# Add multiple packages
gexd add http dio shared_preferences

# Add as dev dependency
gexd add --dev test mockito

# Preview changes without applying
gexd add http --dry-run

🚩 Flags

Flag
Description

--dev

Add package as a dev dependency

--dry-run

Show what would be added without making changes

--git-url <url>

Add package from git repository

--git-ref <ref>

Specify git branch/tag/commit

--path <path>

Add package from local path

--hosted-url <url>

Add package from custom pub server


🎯 Interactive Mode

When run without package name, add enters interactive mode:

  1. πŸ” Search packages on pub.dev

  2. πŸ“‹ Browse results with descriptions and ratings

  3. βœ… Select packages to add

  4. βš™οΈ Choose dependency type (regular/dev)

  5. πŸ“¦ Install automatically


πŸ“Š Examples by Use Case:

Web Packages:

gexd add dio http url_launcher

State Management:

gexd add get riverpod bloc

UI Components:

gexd add flutter_svg cached_network_image

Development Tools:

gexd add --dev test flutter_test mockito

Git Dependencies:

gexd add my_package --git-url https://github.com/user/repo.git
gexd add my_package --git-url https://github.com/user/repo.git --git-ref develop

βœ… What It Does:

  1. πŸ“¦ Package Search - Finds packages on pub.dev

  2. πŸ“ Version Resolution - Determines compatible versions

  3. ✏️ pubspec.yaml Update - Adds dependency entries

  4. ⬇️ Package Installation - Runs dart pub get

  5. πŸ”§ Import Suggestions - Shows import statements


⚠️ Notes:

  • πŸ” Version Constraints: Uses compatible version ranges by default

  • ⚑ Conflict Resolution: Automatically resolves version conflicts

  • πŸ”„ Project Validation: Ensures project is a valid Flutter/Dart project

  • πŸ“‹ Dependency Analysis: Checks for existing dependencies


Generated automatically by gexd_doc

Last updated