Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flutter Plugin/Package: publish a package + reuse native libs #245

Open
2 tasks done
hhstore opened this issue Dec 10, 2020 · 7 comments
Open
2 tasks done

Flutter Plugin/Package: publish a package + reuse native libs #245

hhstore opened this issue Dec 10, 2020 · 7 comments

Comments

@hhstore
Copy link
Owner

hhstore commented Dec 10, 2020

related:

@hhstore
Copy link
Owner Author

hhstore commented Dec 10, 2020

flutter 开发+发布一个库/插件:

  • ✅ flutter 区分 package(库) 和 plugin(插件).

二者区别:

1. 创建包目录:

1.1 package:

创建指令:

  • ✅ 创建包目录:
 flutter create --template=package hello

1.2 plugin:

创建指令:

  • ✅ 创建flutter 插件目录:
# Android: 
flutter create --org com.example --template=plugin --platforms=android,ios -a kotlin hello
flutter create --org com.example --template=plugin --platforms=android,ios -a java hello


# iOS: 
flutter create --org com.example --template=plugin --platforms=android,ios -i objc hello
flutter create --org com.example --template=plugin --platforms=android,ios -i swift hello
  • ✅ 创建完, 添加某平台支持:
flutter create --template=plugin --platforms=web .

2. 发布包:

  • ✅ 发布包指令:
  • ✅ 需要预先准备 gmail 账号, 先注册 dart 开发者平台账号.
# 测试:
flutter pub publish --dry-run

# 发布:
flutter pub publish

3. 原生依赖处理:

@hhstore hhstore changed the title Flutter Plugin: reuse native libs Flutter Plugin: publish a package + reuse native libs Jan 14, 2021
@hhstore hhstore changed the title Flutter Plugin: publish a package + reuse native libs Flutter Plugin/Package: publish a package + reuse native libs Jan 14, 2021
@hhstore
Copy link
Owner Author

hhstore commented Jan 14, 2021

@hhstore
Copy link
Owner Author

hhstore commented Sep 6, 2022

1

@hhstore
Copy link
Owner Author

hhstore commented Sep 6, 2022

@hhstore
Copy link
Owner Author

hhstore commented Sep 6, 2022

iOS + ffi:

示例配置:

MacOS + ffi:

image

Android + ffi:

Windows + ffi :

示例:

@hhstore
Copy link
Owner Author

hhstore commented Sep 6, 2022

Mono Repo for Dart:

  • 统一大仓库

工具:

mono repo:

# 激活工具: 
dart pub global activate melos

注意事项:

  • ✅ 这个项目, 不能使用 国内镜像源, 否则会报错, 提示找不到 Android studio 项目配置模板文件.
function set.proxy.flutter.cn(){
    # mirror: https://mirrors.tuna.tsinghua.edu.cn/help/flutter/
    # 社区:
    export PUB_HOSTED_URL=https://pub.flutter-io.cn
    export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

    # 清华大学:
    #export FLUTTER_STORAGE_BASE_URL="https://mirrors.tuna.tsinghua.edu.cn/flutter"
    #export PUB_HOSTED_URL="https://mirrors.tuna.tsinghua.edu.cn/dart-pub"

}

# defalut use cn mirror:
set.proxy.flutter.cn

# unset:
function unset.proxy.flutter() {
    unset PUB_HOSTED_URL
    unset FLUTTER_STORAGE_BASE_URL
    export PUB_HOSTED_URL=""
    export FLUTTER_STORAGE_BASE_URL=""
    echo "unset flutter proxy"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant