Questions And Answers

More Tutorials

Flutter Dependencies and Packages

Core Packages

Flutter 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 Packages

You 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 Project

Open 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:
sdk: flutter
cupertino_icons: ^0.1.2
scoped_model: ^1.0.1

Import Packages

Once your pubspec.yaml file is setup, you need to install the packages by pulling them from . Normally your editor will assist you with this.

Android Studio

Click ‘Packages Get’ in the action ribbon at the top of pubspec.yaml

Visual Studio Code

Click ‘Get Packages’ located in right side of the action ribbon at the top of pubspec.yaml


Run the command ‘flutter packages get’.

Import & Use Package Code

You 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.
import 'package:flutter/material.dart';
import 'package:scoped_model/scoped_model.dart';

Restart Your App

You will probably need to restart your app if it is running.
That’s it!


In this page (written and validated by ) you learned about Flutter Dependencies and Packages . What's Next? If you are interested in completing Flutter tutorial, your next topic will be learning about: Flutter Package Version Numbers.

Incorrect info or code snippet? We take very seriously the accuracy of the information provided on our website. We also make sure to test all snippets and examples provided for each section. If you find any incorrect information, please send us an email about the issue:

Share On:

Mockstacks was launched to help beginners learn programming languages; the site is optimized with no Ads as, Ads might slow down the performance. We also don't track any personal information; we also don't collect any kind of data unless the user provided us a corrected information. Almost all examples have been tested. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. By using, you agree to have read and accepted our terms of use, cookies and privacy policy.