Creating Flutter Custom Package and Publish in pub.dev

Create a new Flutter package project in Android Studio

Flutter Package Project

After creating project structure will somewhat look like this unlike normal flutter project.

By Default the file name will be created based on the package name you given when creating the flutter package project

I have created the flutter package by sample_text

i’m going to create package of CustomText

Created a CustomText stateless widget

Why I have created this widget ?

When the project size goes bigger and bigger it will be quite difficult to write Text(“”, style=TextStyle()) this widget’s TextStyle again and again fo many times so that’s y I have created a CustomText stateless widget.

Try running flutter packages pub publish — dry-run in your terminal

This command is to check whether any warnings or errors coming in our package

So here I got 2 warnings lets solve those warnings

  1. Create a git Repository and push your project in the github
  2. Remove the author from pubspec.yaml file
Remove the author key from pubspec.yaml

Next after doing the 2 steps add the git repo link in pubspec.yaml

Don’t forget to run pub get

Your pubspec.yaml file somewhat looks like this

Now try running flutter packages pub publish — dry-run in your terminal

You won’t get any warnings

And most importantly update your licence or else you won’t be able to upload the package

Run flutter packages pub publish in your terminal

You will get a succesfull upload message

And you are ready to go 🚀🚀

Note: Your package wont visible immediately in your my-package in pub.dev account it will take some time

Inorder to check you package uploaded or not hit to https://pub.dev/packages/{your_package_name}

My uploaded package is https://pub.dev/packages/sample_text

--

--

--

I’m an IOS, Flutter Developer and now a Blogger

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

What exactly is NoSQL?

Crust and Subsocial Announce Partnership

My Experience With Fisher Yates Algorithm

Quick Intro to Python

[Terraform]: Build Amazon Redis Cache from SNAPShots not are supported. Wait What!!

Recruitment Platform workonblockchain.com — An Open Source Final Gift

Leetcode — Word Pattern — Easy

Overview of Docker

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
Agnel Selvan

Agnel Selvan

I’m an IOS, Flutter Developer and now a Blogger

More from Medium

Async/Await in Flutter

Migrating your Flutter project to null safety

Nusafety errors

Flutter Shared Preferences

Flutter Shared Preferences

Flutter Textformfield Default Value Explained With Example