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

2022-11-02  本文已影响0人  我是小胡胡123

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

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

上一篇 下一篇

猜你喜欢

热点阅读