Flutter Dependencies and Packages
Core PackagesFlutter comes with many packages by default. These are called Core Packages and you don’t need to declare any kind of external dependency to use them.
Non-Core PackagesYou could call these ‘External Packages’. These are packages that are not setup by default. You need to declare these dependencies and pull them into your project to use them.
Declare Dependency in ProjectOpen the pubspec.yaml file in the root of your project and add a dependency. For example, the code below declares dependencies to the flutter sdk, cupertino icons and scoped_model. Note how some
dependencies specify the version, some don’t:
Import PackagesOnce your pubspec.yaml file is setup, you need to install the packages by pulling them from https://pub.dartlang.org/ . Normally your editor will assist you with this.
Android StudioClick ‘Packages Get’ in the action ribbon at the top of pubspec.yaml
Visual Studio CodeClick ‘Get Packages’ located in right side of the action ribbon at the top of pubspec.yaml
Command-LineRun the command ‘flutter packages get’.
Import & Use Package CodeYou import the package code in the usual manner using the ‘import’ statement at the top of your code. For example, the code imports the flutter material package and the scoped model package.
Restart Your App
You will probably need to restart your app if it is running.