七、将 Dart 包推送到中央仓库中
执行如下命令 , 将 Dart 包推送到中央仓库中 ;
flutter packages pub publish --server=https://pub.dartlang.org
D:\002_Project\002_Android_Learn\flutter_package>flutter packages pub publish Publishing flutter_package 0.0.1 to https://pub.flutter-io.cn: |-- .gitignore |-- .metadata |-- CHANGELOG.md |-- LICENSE |-- README.md |-- lib | '-- flutter_package.dart |-- pubspec.yaml '-- test '-- flutter_package_test.dart Publishing is forever; packages cannot be unpublished. Policy details are available at https://pub.dev/policy Do you want to publish flutter_package 0.0.1 (y/N)?
输入 y 然后点击回车 , 这里弹出一个链接 , 需要到该地址登录 Google 账号 ;
Do you want to publish flutter_package 0.0.1 (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%2 F%2Flocalhost%3A57747&code_challenge=iplyOXdxiNSnXI7z1Xza2wrHOfTUx-LWyiKM3wVlokg&code_challenge_method=S256&scope=openid+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email Then click "Allow access". Waiting for your authorization...
选择了要登录的账号后 , 需要进行手机验证 ;
输入手机验证码 ;
授权成功 ;
终于上传成功了 :
D:\002_Project\002_Android_Learn\flutter_package>flutter packages pub publish --server=https://pub.dartlang.org Publishing flutter_package_first_demo 0.0.1 to https://pub.dartlang.org: |-- .gitignore |-- .metadata |-- CHANGELOG.md |-- LICENSE |-- README.md |-- lib | '-- flutter_package_first_demo.dart |-- pubspec.yaml '-- test '-- flutter_package_test.dart Publishing is forever; packages cannot be unpublished. Policy details are available at https://pub.dev/policy Do you want to publish flutter_package_first_demo 0.0.1 (y/N)? y Uploading... Successfully uploaded package. D:\002_Project\002_Android_Learn\flutter_package>
插件地址是 : https://pub.dev/packages/flutter_package_first_demo
发布插件包坑挺多 : 报错信息一个接着一个 , 研究了一晚上 ;
【错误记录】发布 Flutter 插件包报错 ( It‘s strongly recommended to include a “homepage“ or “repository“ field )
【错误记录】发布 Flutter 插件包报错 ( Failed to upload the package.pub finished with exit code 1 )
【错误记录】发布 Flutter 插件包报错 ( ‘gmail.com‘ has insufficient permissions to upload new versions of package)