Package Management for Dart, Flutter

By pjain      Published April 21, 2020, 3:42 a.m. in blog Programming   

Part of Series - Flutter/Dart Series

Flutter/Dart Dependencies 101

Dart Pubspec.yaml file 101

Flutter Dependencies 101

Information on managing package dependencies can be found here:

Importing a Dart Package dependency - ?same for Flutter?

  • Normal pub dev dependency

  • Local path dependency - absolute path

  • Local path dependency - for 1 directory up

    /prjdir /lib <-- package to use /example (pubspec.yaml) /lib

    dependencies: plugin1: path: ../

  • Git dependency

    dependencies: plugin1: git: url: git://

Flutter/Dart Packages

Packages 101

Flutter, Dart Building Intermediate

Different flavors in Flutter?

Can we have environments with different yaml such as test, prod, stag and so on. Like the flavor of android.

  • By design, different developers or environments are not allowed to have different pubspec.yaml.

  • So if you want to eg test a plugin in your local setup, then your own development environment should NOT be reflected in the shared source code. The best solution is to include the git path or some other common location in the shared pubspec.yaml and modify your local file to point to your relative path. Your local pubspec.yaml should of course not be checked into source control.

  • Have you considered the workaround of having the file, and then having a small script you can run that renames pubspec.yaml to pubspec.old and pubspec.local.yaml to pubspec.yaml when you start developing, and then back again before hitting source control?


There are no comments yet

Add new comment

Similar posts

List++ Advanced Application Features

Interview Questions in Flutter

NAV: URL Launcher, Deep Links

NAV: Navigation Drawers