How to Install Packages in Flutter?
Last Updated :
13 Oct, 2021
In this article, we will look into the process of installing packages in flutter. Before we start incorporating a package, first let's understand briefly what are Flutter Packages.
Flutter packages are open source libraries of code written and maintained by someone else, which we can incorporate in our project to maximize our efficiency and minimize our efforts. The whole process of installing a Flutter package can be broken down into 3 main steps.
Installing Flutter Packages:
Follow the below steps to install flutter packages:
Step 1: Finding the Package.
First of all head over to Pub.dev, where you can find all the flutter compatible packages. Now, if you already know which package you need to install, directly search the name of the Package in the search box. But if you don't know exactly which package to install, search the keyword in the search box. Now, we need to find the appropriate package which not only meets our requirements but is also popular and well maintained.
We know this by looking into the score displayed on the right of the package name.
The score of a Package
We can also look in the Readme section of that package to know about the work the package can do. If you're still confused head over to the article on Top Ten Flutter Packages by GeeksForGeeks.
Step 2: Installing the Package
Now that we have found our desire package, go to the Installing tab of that package.
Tabs in a package in Pub.dev
There are many ways to install a package but the most common and easy way is by adding it to your project's pubspec file. Simply copy the code written under dependencies and go to your project's pubspec.ymal file.
code for pubspec.ymal
Now paste this under the "dependencies" in your pubspec.ymal file.
Note: Maintain the indentation while pasting..
Dependencies
Now to finally install it enter the command in terminal flutter pub get and hit enter. Or if you are using Android studio just click on Packages get in the top right corner.
Android Studio options
Step 3: Importing the Package
Again go to the page in Pub.dev and copy the import statement in the Installing Tab.
Import statement
Paste this in the header of your dart file.
Import
Now we can use the functions/widgets provided by the package.
Note: Sometimes you might need to stop and restart the app for it to work properly.
If you want to know more about the package read the Readme and Examples tab of the package in Pub.dev, usually, the authors of the package explain all the things in the documentation. They also provide sample code in the Example tab, also you can see the score of that package in the Score tab.
For more information on how to use packages and installing head over to Flutter's Documentation. For more articles on Flutter stay tuned on GeeksForGeeks.
Similar Reads
How to Install HTTP Package in Flutter?
Flutter is Googleâs Mobile SDK to build native iOS and Android apps from a single codebase. When building applications with Flutter everything towards Widgets â the blocks with which the flutter apps are built. The User Interface of the app is composed of many simple widgets, each of them handling o
2 min read
How to Import Local Package in Flutter?
Flutter is a framework that is used for developing cross-platform applications for Android, iOS, Linux, macOS, Windows, and other web applications using a single source code and it was developed by Google. Flutter is a free and open-source software development kit for developing mobile applications.
4 min read
How to Change Package Name in Flutter?
Every Flutter app has a package name that uniquely identifies your app on the Google Play Store and Apple App Store. In this article, we will learn how to change the package name with a simple and easy method. The package name is basically a unique identity to identify that app on App Store, Play St
2 min read
How to Install Shared Preferences in Flutter?
Shared preferences in flutter applications are used to store data in Local Storage. Shared Preferences store the data in a key-value pair. and we can also get data in a key-value pair using inbuilt functions. We can save large data in local storage or our Phone storage with the help of SQLite databa
2 min read
How to Install Flutter in Eclipse?
Flutter is a framework for building cross-platform applications (android, ios, web) which use Dart as its programming language. Before IDEs like Android Studio and VS code became popular, Eclipse used to be heavily used by developers. Now we can install dart inside our Eclipse IDE with the help of t
2 min read
How to Install cocoaPods in Flutter?
CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects. Cocoapods helps you to manage and incorporate third-party libraries into your project without getting concerned about setting up and configuring your project. Steps For Installation of CocoaPodsThere are two ways to install
2 min read
How to Install Flutter on Linux?
In this article, we will learn how to install Flutter in Linux Flutter is an open-source UI software development kit created by Google. It is used to develop cross-platform applications for Android, iOS, Linux, Mac, Windows, Google Fuchsia, and the web from a single codebase. Installing Flutter on L
2 min read
How to Install Deb Files (Packages) on Ubuntu
Installing the application on Windows is an easy task, as we just need to download the .exe file of the application and complete the installation in simple clicks, but the installation of the application on Linux or Ubuntu is quite different from Windows. We need to execute the commands and perform
7 min read
How to Install Flutter on Windows?
Flutter is Google's portable user interface (UI) toolkit. It is used to build and develop eye-catching, natively built mobile, desktop, and web applications from a single codebase. Flutter is free, open-sourced, and compatible with existing code. Due to its user-friendly interface and fairly simple
9 min read
How to Import intl Library in Flutter?
Flutter supports using shared packages contributed by other developers to the Flutter and Dart ecosystems. This allows the developers to quickly build an app without having to develop everything from scratch. One such very helpful and Flutter Favourite package is the intl package published by the da
2 min read