How to create own package in flutter

1 Min Read

To create your own package in Flutter, follow these steps:

  1. Create a new directory for your package. This directory should be separate from your main Flutter project.
  2. Inside the directory, run the following command in your terminal:
flutter create .

This will create a basic Flutter project structure inside the directory.

  1. Modify the pubspec.yaml file to include information about your package, including its name, description, and any dependencies it has.
  2. Write your package code and test it thoroughly. You can use the flutter test command to run tests for your package.
  3. When your package is ready, you can publish it to the repository by running the following command in the terminal:
flutter packages pub publish
  1. Follow the on-screen instructions to publish your package.

Note that publishing a package requires you to have a Pub profile, which you can create by running flutter packages pub global activate pub.

Share this Article
Leave a comment