1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Flutterの自作ライブラリを作って公開する方法

Last updated at Posted at 2019-10-30

loading_textなるライブラリを公開したので、そのときに得た知識を残しておきます。

Flutterライブラリの作成

$ flutter create --template=package <name>

でFlutterライブラリのプロジェクトを作ることができます。
このコマンドで作られるプロジェクトはlibのみで、androidiosなどプラットフォーム非依存のdartコードだけ書けます。

$ flutter create --template=plugin <name>

でプラットフォームのコードも書けるようですが、今回は試していません。

公開の手順

まずは以下のコマンドでプロジェクトに不備がないかチェックします。

$ pub publish --dry-run

私の環境では、pubspec.ymlにhomepageとauthorの項目が足りないことで、
怒られました。

修正したら、以下のコマンドで公開です。

$ pub publish

途中、Googleアカウントでログインが求められるので、URLにアクセスしてログインしましょう。
しばらくすると、公開が完了します。

注意点

公開したパッケージは削除することはできないみたいです。

Publishing is forever
Keep in mind that publishing is forever. As soon as you publish your package, users can depend on it. Once they start doing that, removing the package would break theirs. To avoid that, pub strongly discourages deleting packages. You can always upload new versions of your package, but old ones will continue to be available for users that aren’t ready to upgrade yet.

適当翻訳では、「削除できてしまうとそのパッケージを使っているユーザーが困っちゃうから、させないようにしているよ。」です。
バージョンを上げて、上記コマンドを打ち直せば、新しいバージョンをアップロードできますが、古いものも残り続けるようです。

非公開にすべき情報を上げないように注意しましょう。

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?