27

enter image description here I want know different between dependencies and dev_dependencies.

When i put package in dependencies/dev_dependencies ?

What put package in dependencies/dev_dependencies make size APK be bigger? ( i not yet try release apk to see different size)

Because i use extension in visual studio code Pubspec Assist, this extension auto add dependencies to pubspec.yaml

Thank's

Zeffry Reynando
  • 3,445
  • 12
  • 49
  • 89

3 Answers3

34

dependencies

List of plugins that we have to include while deploying your App after completion of your development stage.

dev_dependencies

List of plugins that you want to try out at the development stage to test the apps at development stage.

For example: In the development stage, we use Mockito and test plugins and SDK to write the test cases and to test the complete behaviour of the app. These kind of plugins and SDK's we include in

dev_dependencies

So in the release apps, there is no need of adding these plugins or sdk support.

iDecode
  • 22,623
  • 19
  • 99
  • 186
hemandroid
  • 568
  • 4
  • 12
  • Not sure why, but if I remove my dev_dependencies from pub spec and then build a release and obfuscated APK everything works where if I don't remove the dev_dependencies, it crashes. Seems like some dev_dependencies do leak to the obfuscated release APK.. I build the APK like using this command: flutter build apk --debug -t /main.dart --build-number 1 --obfuscate --split-debug-info=debug_info – user3193413 Aug 16 '22 at 10:25
  • @user3193413 same observation. Having to deal with a package that causes problems only in release mode, but I need it in debug mode. I can't fix the issues from it in release mode by moving the package to dev_dependencies. I have to remove the package entirely to fix my problem. dev_dependencies seem to have only meaning, but not enforce it. – Martin Braun Aug 11 '23 at 01:36
  • @MartinBraun May I know which package you're using and facing the problem with release mode build? – hemandroid Aug 11 '23 at 12:25
  • @hemandroid https://github.com/ufukhawk/safe_device/issues/33 (I moved to `device_info_plus` to fix it, though) – Martin Braun Aug 12 '23 at 09:10
19

dependencies are packages that are included in your app during compilation while dev_dependencies are packages that you use during developing your app and these are not included in the APK

digitaljoni
  • 1,357
  • 1
  • 9
  • 12
  • 2
    Sorry i want little ask , how i know what packages i must put in dev_dependencies/dependencies ? as example i have package `Image picker ,http, splashscreen` between this package ,Which one i must put in dependencies/dev_dependencies ? – Zeffry Reynando Sep 02 '19 at 04:21
  • 1
    usually it will be documented in the pub.dev examples... but to make it simple... if the app would need the package during runtime, then include it `dependencies`... your examples: `Image picker ,http, splashscreen` are going to be used in the app itself, so you should include them to dependencies – digitaljoni Sep 02 '19 at 05:38
  • 1
    to give you an example of a package to be placed in dev_dependencies, check out: flutter_launcher_icons... this is a package which enables you to create all the app icons for your app... which you would only need to do during the development of the app... – digitaljoni Sep 02 '19 at 05:41
  • But it is mentioned to add splashScreen to dev_dependencies and it is required at runtime right? @digitaljoni – Bensal Aug 03 '20 at 04:20
  • 1
    @Bensal, usually dev_dependencies create files for you to use on your apps... and you only need to run them during development... in the case of flutter_launcher_icons and flutter_native_splash... it will create the images and do some code changes for you... so the created images and code changes, you will include that to your repo. i hope this helps. – digitaljoni Aug 05 '20 at 14:18
1

dev_dependencies are only required for development or which are used to build your bundle. Ex: es-lint

dependencies should contain libs and framewors your app is built on.Ex: intl

dev_dependencies are modules which are only required during development, while dependencies are modules which are also required at runtime.

Robin
  • 4,902
  • 2
  • 27
  • 43
  • so if i put all package in `dependecies` make my apk size be bigger than i put all my package in `dev_dependecies` ? or i cant build release apk if my package in `dev_dependecies`? – Zeffry Reynando Sep 02 '19 at 04:24
  • 2
    You shouldn't put all packages in `dependencies`. But must put all packages in `dependencies` which is required at run time. Suppose: `intl` is a packages for date format, if you put it in `dev_dependencies` - date formatting doesn't work in your app. So you must put `intl` in dependencies. Packages under `dependencies` will increase your apk size. – Robin Sep 02 '19 at 04:40