美文网首页
2022-11-03 搭建私有flutter pub仓库

2022-11-03 搭建私有flutter pub仓库

作者: 我是小胡胡123 | 来源:发表于2022-11-02 15:25 被阅读0次

1、搭建pub server

官方私有pub 仓库地址

git clone https://github.com/dart-archive/pub_server.git
cd pub_server
flutter pub get

启动pub server服务

dart example/example.dart -d /tmp/package-db

2、去掉google 登录验证

image.png Xnip2022-11-03_14-48-54.jpg

如果2.x版本,则会有以上截图所示的验证。
如果是flutter 3.x 则不需要去google 验证,是可以直接发布到私有pub server仓库的。

git clone https://github.com/ameryzhu/pub
cd pub
flutter pub get
dart --snapshot=my.pub.snapshot ./bin/pub.dart 

将my.pub.snapshot 替换掉
FLUTTER_INSTALL/bin/cache/dart-sdk/bin/snapshots/pub.dart.snapshot

  • google登录是pub命令行程序决定的。并不是pub server要求的。
    如果要修改为公司的邮箱邮政或者移除鉴权验证,需要修改pub 命令行程序源代码,重新编译一份新的pub 命令。

3、发布package

创建package

 flutter create --template=package test_package

修改 pubspec.yaml

name: test_package
description: A new Flutter package project.
version: 0.0.4
author: test
homepage: http://gitlab.com/test
#私有pub仓库地址
publish_to: http://localhost:8080

发布package

cd test_package
flutter pub publish
image.png

4、使用 package

创建test

flutter create test

方式1:
修改export PUB_HOSTED_URL=http://localhost:8080

  test_package: ^0.0.1

方式2:

  test_package:
    hosted:
      name: test_package
      url: http://localhost:8080
    version: ^0.0.1

参考:
https://blog.csdn.net/blog_jihq/article/details/115380948
https://zhuanlan.zhihu.com/p/433169569

相关文章

网友评论

      本文标题:2022-11-03 搭建私有flutter pub仓库

      本文链接:https://www.haomeiwen.com/subject/vsretdtx.html