Image for post
Image for post

How to Create, Publish and Manage Flutter Packages

onat çipli
Jul 12, 2019 · 5 min read

Dart Package vs Plugin Package

Dart packages: Only packages are written using Flutter and Dart SDKs independent of native platforms such which are Android and iOS. The meet_network_image package is an example of a Dart package.

Plugin packages: A special Dart package for Android (using Java or Kotlin) and/or iOS (using ObjC or Swift) platform-specific application that includes an API written in the Dart code. The image_picker plugin allows you to take pictures or retrieve an existing image from your gallery using separate APIs for iOS and Android.

Creating Dart Package

Step 1

Open the command line in your operating system, and type the following line with your package_name


If you are using an IntelliJ IDEA or Android Studio, you can convert the project type to a package when creating a Flutter project.

Image for post
Image for post

Step 2

Let’s put your project to the GitHub

After opening a repository via Github, you can upload these commands one by one from the directory where your project is located to Github, remember to enter your own remote address!

After pushing all project files to GitHub repository, We can begin with editing pubspec.yaml.

Image for post
Image for post

This is how our project files look like, lib/ is the folder that we will create and write the package codes
(In Step 3)


Let's begin with editing pubspec.yaml file.

Image for post
Image for post

In the description part, you can write a brief description of the package and what the package does.

In the author part, you need to write to people who support this package by using the following pattern

FirstName LastName<E-mail>

Onat Çipli<>

In the homepage part, you can enter the package repository URL

As you can see at the following part, we’ll list the changes in our package one by one in the file.

Image for post
Image for post


Choose an open source license,

I will use MIT LICENSE, you only need to write your name and the year

Copyright © [year] [fullname]

Step 3 (Writing package code /lib)

Now it’s time for implementing our dart package code,

Image for post
Image for post

We will delete the codes inside the custom_alert_box.dart file, to be able to create our code. (You need to fix test folder when you delete the code inside the custom_alert_box.dart, you can comment on the tests for now)

I just create a CustomAlertBox class, and inside that class, I create a static method named showCustomAlertBox to be able to show an alert box with using our package.

Step 4

Creating Example

Our package should include example project which using our Dart package code with help of that example project you can easily test your package code, by the way, is an example for other users to learn how to use your package.

In our package directory,

Image for post
Image for post

We are creating a new Flutter project in our Dart Package directory as bellow and inside the example project inside the pubspec.yaml file we need to add our package like following,

After that point, we able to import our package and use it in the example project.

Image for post
Image for post

Step 5(Publish package)

Before this step we need to push all changes to GitHub remote.

We able to publish our package to with the following command,

flutter packages pub publish

After that, Command line gives you a link to verify your E-mail and send you a mail about your package,

Dear package maintainer, has published a new version (0.0.1) of the
custom_alert_box package to the Dart package site (

For details, go to

If you have any concerns about this package, file an issue at

Thanks for your contributions to the Dart community!

With appreciation, the Dart package site admin

Image for post
Image for post

Managing Package

Every time you make changes in your package, you can publish the new version with flutter packages pub publish but you need to push all the changes to GitHub and do not forget to write the changes to your, change pubspec.yaml version

Package source code custom_alert_box
example source code
Published package
custom_alert_box 0.0.1 in

You can reach and follow me on twitter @CipliOnat or Linkedin.

Flutter Community

Articles and Stories from the Flutter Community

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store