检查代码
$ 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.
如果发布失败,可以在上面命令后加-v,会列出详细发布过程,确定失败在哪个步骤,也可以看看issue上的解决办法。
常见问题
Flutter 安装路径缺少权限,导致发布失败,参考
sudo flutter packages pub publish -v