Flutter Plugin如何發佈到 pub倉庫

檢查代碼

$ flutter packages pub publish --dry-run
複製代碼
Publishing flutter_kit 1.0.0 to https://pub.dartlang.org:
|-- .gitignore
|-- CHANGELOG.md
|-- LICENSE
|-- README.md
|-- android
|   |-- .gitignore
|   |-- build.gradle
|   |-- gradle.properties
|   |-- settings.gradle
|   '-- src | '-- main
|           |-- AndroidManifest.xml
|           '-- kotlin | '-- com
|                   '-- nsky | '-- flutter_kit
|                           '-- FlutterKitPlugin.kt |-- example | |-- .gitignore | |-- .metadata | |-- README.md | |-- android | | |-- app | | | |-- build.gradle | | | '-- src
|   |   |       |-- debug
|   |   |       |   '-- AndroidManifest.xml | | | |-- main | | | | |-- AndroidManifest.xml | | | | |-- kotlin | | | | | '-- com
|   |   |       |   |       '-- nsky | | | | | '-- flutter_kit_example
|   |   |       |   |               '-- MainActivity.kt | | | | '-- res
|   |   |       |       |-- drawable
|   |   |       |       |   '-- launch_background.xml | | | | |-- mipmap-hdpi | | | | | '-- ic_launcher.png
|   |   |       |       |-- mipmap-mdpi
|   |   |       |       |   '-- ic_launcher.png | | | | |-- mipmap-xhdpi | | | | | '-- ic_launcher.png
|   |   |       |       |-- mipmap-xxhdpi
|   |   |       |       |   '-- ic_launcher.png | | | | |-- mipmap-xxxhdpi | | | | | '-- ic_launcher.png
|   |   |       |       '-- values | | | | '-- styles.xml
|   |   |       '-- profile | | | '-- AndroidManifest.xml
|   |   |-- build.gradle
|   |   |-- gradle
|   |   |   '-- wrapper | | | '-- gradle-wrapper.properties
|   |   |-- gradle.properties
|   |   '-- settings.gradle | |-- ios | | |-- Flutter | | | |-- AppFrameworkInfo.plist | | | |-- Debug.xcconfig | | | '-- Release.xcconfig
|   |   |-- Podfile
|   |   |-- Runner
|   |   |   |-- AppDelegate.swift
|   |   |   |-- Assets.xcassets
|   |   |   |   |-- AppIcon.appiconset
|   |   |   |   |   |-- Contents.json
|   |   |   |   |   |-- Icon-App-1024x1024@1x.png
|   |   |   |   |   |-- Icon-App-20x20@1x.png
|   |   |   |   |   | (10 more...)
|   |   |   |   |   |-- Icon-App-76x76@1x.png
|   |   |   |   |   |-- Icon-App-76x76@2x.png
|   |   |   |   |   '-- Icon-App-83.5x83.5@2x.png | | | | '-- LaunchImage.imageset
|   |   |   |       |-- Contents.json
|   |   |   |       |-- LaunchImage.png
|   |   |   |       |-- LaunchImage@2x.png
|   |   |   |       |-- LaunchImage@3x.png
|   |   |   |       '-- README.md | | | |-- Base.lproj | | | | |-- LaunchScreen.storyboard | | | | '-- Main.storyboard
|   |   |   |-- Info.plist
|   |   |   '-- Runner-Bridging-Header.h | | |-- Runner.xcodeproj | | | |-- project.pbxproj | | | |-- project.xcworkspace | | | | '-- contents.xcworkspacedata
|   |   |   '-- xcshareddata | | | '-- xcschemes
|   |   |           '-- Runner.xcscheme | | '-- Runner.xcworkspace
|   |       '-- contents.xcworkspacedata | |-- lib | | '-- main.dart
|   |-- pubspec.yaml
|   '-- test | '-- widget_test.dart
|-- flutter_kit.iml
|-- ios
|   |-- .gitignore
|   |-- Assets
|   |   '-- .gitkeep | |-- Classes | | |-- FlutterKitPlugin.h | | |-- FlutterKitPlugin.m | | '-- SwiftFlutterKitPlugin.swift
|   '-- flutter_kit.podspec |-- lib | '-- flutter_kit.dart
|-- pubspec.yaml
'-- test '-- flutter_kit_test.dart

複製代碼
flutter packages pub publish

Looks great! Are you ready to upload your package (y/n)? y
Pub needs your authorization to upload packages on your behalf.
In a web browser, go to https://accounts.google.com/o/oauth2/auth?access_type=offline&approval_prompt=force&response_type=code&client_id=818368855108-8grd2eg9tj9f38os6f1urbcvsq399u8n.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A51876&scope=openid+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email
Then click "Allow access".

Waiting for your authorization...
Authorization received, processing...
Successfully authorized.
Uploading...
Successfully uploaded package.
複製代碼

pub.dev/packages/fl…android

若是發佈失敗,能夠在上面命令後加-v,會列出詳細發佈過程,肯定失敗在哪一個步驟,也能夠看看issue上的解決辦法。ios

常見問題

Flutter 安裝路徑缺乏權限,致使發佈失敗,參考git

sudo flutter packages pub publish -v
複製代碼
相關文章
相關標籤/搜索