How to Import Local Package in Flutter?
Last Updated :
25 Mar, 2022
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. Developers use Dart Programming Language for building mobile Applications using Flutter Framework. Dart is a typed object programming language that majorly focuses on UI development and its syntax is very similar to JavaScript. To know more about flutter, you can follow the flutter tutorial.
Why Flutter?
Flutter enables us to create both android and iOS applications using a single source code and programming Language which makes the developers complete the project in less time and in an efficient way. Everything in flutter is treated as a Widget and Flutter also has a widget library that contains elements such as buttons, scaffold, text areas, and many more which can be reused.
As we see in the industry many companies are preferring the Flutter framework along with the dart programming language for developing mobile applications because of these features.
- Easy to learn.
- Cost-effective.
- Great performance.
- Increased productivity.
- Available on different IDEs.
- Great documentation & community.
And now coming into the article we are going to discuss how to import local packages in a flutter. Packages are the predefined codes in any programming language which are also called libraries. By importing them we use all the functionalities like methods and attributes in them in the host module. By this, we can reduce the lines of code.
Flutter packages are open-source libraries that can be used by anyone at no cost. It not only reduces the lines of code but also minimizes the effort of the developer and maximizes the efficiency of the project. Before going into the steps of implementation, we have to know what a package is.
The package is a set of code that would be reused at any part of our project by just importing name without rewriting all the code again and adding that functionality, it can be a set of projects imported into a large project also. Packages would be two types that are user-defined which are written in your code as separate modules and used in your other module, and library packages that should be installed from some source of internet and need to be imported. Now we are going into the detailed steps on how to import the local packages in a flutter.
Case 1:
If you want to import your module as a package into another module.
Step 1: To set up VSCode you can follow the VSCode tutorial. For example, you have a welcome screen and get started screen and when you click on the Next button on the welcome screen it should redirect to the Get started screen.

Step 2: We have to import the Get Started module as a package into the Welcome Screen.
Importing a module as a local package
Now it's sorted out and we get all functionalities present in that imported module to the host module.
Case 2:
If we want to import a module that is predefined Library in flutter or Dart Programming Language.
Step 1: We have to install the library from the dev platform of the Flutter or Dart. By finding the library by name in Dev Platform, like https://pub.dev/packages/firebase_auth. Here firebase_auth is the library name and follow the instructions in Installing button on the page.
Search for your package name here
Step 2: Then you can find it by using a command to add the package into our code. For adding the package into our code, we have to add the library as a dependency into our pubspec.yaml file in our development environment.
By using the command.
$ flutter pub add Library name
This will directly add the dependency to the pubspec.yaml file. We can also add the dependency manually without using the above command. Open the Pubspec.yaml file and add the dependency as library name: version number as shown in the figure below.

Then it will automatically install your package into your system in either of the above two ways. Now you are pending with just importing the package into the required module. By using,
import 'Package name';
Or using the complete path of the file name.
import 'package:path/package name';
This is the process of importing Local packages into flutter in different scenarios.
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 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
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 Import Data From One Page to Another in Flutter?
Flutter is Googleâs Mobile SDK to build native iOS and Android, Desktop (Windows, Linux, macOS), Web apps from a single codebase. When building applications with Flutter everything towards Widgets â the blocks with which the flutter apps are built. They are structural elements that ship with a bunch
5 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 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
Flutter - How to Integrate Mapbox
Maps have become an aspect of our routines. Whether you're exploring a city looking for a coffee shop or keeping tabs on delivery maps is incredibly valuable. When it comes to creating apps incorporating maps not only improves the user experience but is also frequently necessary, for applications th
7 min read
How to Import Existing Flutter Project in Android Studio?
In this article, we are going to see the process of importing an existing flutter Project into the Android Studio. This is going to be quite easy, we just have to take care of some steps involved in it. Before going on the main topic let's have brief info about Flutter and Android Studio as well. Fl
3 min read
How to Import a Flutter Project from GitHub?
Importing a project from GitHub is a very common practice of developers. When we want to get any project from an online source like GitHub then we can easily import or download it to our system. Sometimes, developers need to get the small module of application and if that module is available on GitH
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