# NativeDemo
**Repository Path**: hakwolf/NativeDemo
## Basic Information
- **Project Name**: NativeDemo
- **Description**: flutter ffi 调用demo
- **Primary Language**: Dart
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 3
- **Created**: 2021-05-22
- **Last Updated**: 2021-05-22
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# NativeDemo
A new Flutter project.
## Getting Started
# ffi介绍
> Dart 2.5 已经开始,增加了dart:ffi 外部函数接口,用于直接从 Dart 调用 C 代码。
#
由于原生应用会涉及到C层调用,ffi的产生,就可以实现flutter底层跨平台,摆脱对原生应用原生库的依赖,从而减少flutter和原生项目的交互。
eg: 本文就是将网络请求彻底采用flutter和C实现,获取和加密网络参数不再通过ios或者android的原生网络库获取
### 参考链接
* [1. 动态库引用例子](https://www.kikt.top/posts/flutter/ffi/2-first-party/)
* [2. 官网,参考demo struts](https://dart.cn/guides/libraries/c-interop)
* [3. 字符串处理1](https://www.colabug.com/2020/0804/7591188/)
* [4. C语言基本函数的调用](https://www.jianshu.com/p/55e4fec2dfb6)
#### 项目地址
* [1. Demo地址](https://gitee.com/leixun/NativeDemo)
* [2. C语言实现地址]()
* [3. 教资项目地址]()
# 一、Demo模拟调用(根据参考链接实现了项目)
项目地址:见项目地址1
Demo运行步骤:
1. 配置ndk路径
2. android 运行主脚本生成相关so ./build_android.sh
3. ios 运行主脚本生成动态库,启动项目需要注意是否依赖,android也需要注意
遇到的大小坑
1. ios运行失败 需要添加动态库
2. ffi/dart导入 Utf8 需要增加依赖
3. android运行失败,需要主动配置jni路径,或者将包拷贝的项目默认jni路径上
# 二、实战模拟 公司登陆校验