Skip to content
root / Using external packages in your Flutter project

Using external packages in your Flutter project

Hi, Guys, I am back with another article, and this time I am going to show how to import external packages from pub.dev to your Flutter project, pub.dev has many packages for different purposes and many for the same. For this article, I will be using a package called Font Awesome Flutter which is a material style set of icons which is for a wide range of icons for your project.

This link leads to the pub.dev site. Once you are there search for Font Awesome Icons

makes sure that you check for the pub points, overall score, and popularity before using it in your project.

now open the <strong>pubspec.yaml</strong> file in the root of your app.

there you should see something like this.

dependencies:
  flutter:
  sdk: flutter
  cupertino_icons: ^1.0.0
  font_awesome_flutter: ^8.10.0 # This is the part you need to add

Add this to your dependencies part and save <strong>pubspec.yaml</strong> to verify the package from pub.dev.

In your main.dart import the following

this is similar to the material package we import at the start to use material widgets.

Now replace the Icons.add with <strong>FontAwesomeIcons.plus</strong>

if you run your application you will see the following, If you did not stop your app you will get a question mark inside your box. this is because we have modified a file that can’t be updated without running our app.

Tags: