Linux command
flutter-pub 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Get dependencies
flutter pub get
Update dependencies
flutter pub upgrade
Add package
flutter pub add [package_name]
Remove package
flutter pub remove [package_name]
Run build runner
flutter pub run build_runner build
说明
flutter pub manages Dart package dependencies for Flutter projects. It installs, updates, and resolves packages from pub.dev, the Dart package repository. The tool reads pubspec.yaml for dependency specifications and generates pubspec.lock for reproducible builds. It handles transitive dependencies and version conflicts automatically. flutter pub enables code reuse through thousands of community packages for networking, state management, UI components, and more.
参数
- get
- Install dependencies from pubspec.yaml.
- upgrade
- Update to latest compatible versions.
- add _PACKAGE_
- Add package to dependencies.
- remove _PACKAGE_
- Remove package from dependencies.
- run _SCRIPT_
- Run package script.
- outdated
- Show outdated packages.
- deps
- Show the dependency tree.
- publish
- Publish the package to pub.dev.
- downgrade
- Downgrade dependencies to the lowest versions allowed by pubspec.yaml.
- cache
- Inspect, repair, or clean the local pub package cache.
- --help
- Display help information.
FAQ
What is the flutter-pub command used for?
flutter pub manages Dart package dependencies for Flutter projects. It installs, updates, and resolves packages from pub.dev, the Dart package repository. The tool reads pubspec.yaml for dependency specifications and generates pubspec.lock for reproducible builds. It handles transitive dependencies and version conflicts automatically. flutter pub enables code reuse through thousands of community packages for networking, state management, UI components, and more.
How do I run a basic flutter-pub example?
Run `flutter pub get` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does get do in flutter-pub?
Install dependencies from pubspec.yaml.