当前位置: 首页 > news >正文

鸿蒙harmonyos next flutter混合开发之开发FFI plugin

  • 创建FFI plugin summation,默认创建的FFI plugin是求两个数的和
flutter create --template=plugin_ffi summation --platforms=android,ios,ohos
  • 创建my_application
flutter create --org com.example my_application
  • 在my_application项目中文件pubspec.yaml引用summation
  summation:path: /Users/administrator/Desktop/workspace/summation
  • my_application中调用summation
import 'package:flutter/material.dart';
import 'package:summation/summation.dart' as summation;void main() {runApp(const MyApp());
}class MyApp extends StatefulWidget {const MyApp({super.key});@overrideState<MyApp> createState() => _MyAppState();
}class _MyAppState extends State<MyApp> {int sumResult = 0;int sumAsyncResult = 0;@overridevoid initState() {super.initState();sumResult = summation.sum(1, 2);summation.sumAsync(3, 4).then((value) {sumAsyncResult = value;setState(() {});});}@overrideWidget build(BuildContext context) {const textStyle = TextStyle(fontSize: 25);const spacerSmall = SizedBox(height: 10);return MaterialApp(home: Scaffold(appBar: AppBar(title: const Text('my_application调用ffiplugin'),),body: SingleChildScrollView(child: Container(padding: const EdgeInsets.all(10),child: Column(children: [Text('同步求和sum(1, 2) = $sumResult',style: textStyle,textAlign: TextAlign.center,),spacerSmall,Text('异步求和sum(3, 4) = $sumAsyncResult',style: textStyle,textAlign: TextAlign.center,),],),),),),);}
}
  • 效果展示

http://www.lryc.cn/news/456466.html

相关文章:

  • oracle数据库安装和配置
  • 猫玖破密啦
  • SpringBoot框架:服装生产管理的现代化工具
  • Android Preference的使用以及解析
  • HCIP——GRE和MGRE
  • 微信小程序——音乐播放器
  • OceanBase 4.x 部署实践:如何从单机扩展至分布式部署
  • 大数据新视界 --大数据大厂之TeZ 大数据计算框架实战:高效处理大规模数据
  • docker详解介绍+基础操作 (三)
  • 【大语言模型-论文精读】谷歌-BERT:用于语言理解的预训练深度双向Transformers
  • 【Java】集合中单列集合详解(一):Collection与List
  • 【Fine-Tuning】大模型微调理论及方法, PytorchHuggingFace微调实战
  • 清华系“仓颉”来袭:图形起源:用AI颠覆字体设计,推动大模型商业化落地
  • 分布式一致性协议的深度解析:Paxos与Raft
  • ai写作,五款软件助你快速写作!
  • 解决JavaScript 数学运算精度丢失的问题
  • mysql学习教程,从入门到精通,SQL窗口函数(38)
  • gbase8s数据库实现黑白名单的几种方案
  • Qt-窗口布局按钮输入类
  • Apache DolphinScheduler社区9月进展记录
  • 在docker中安装并运行mysql8.0.31
  • C++ | Leetcode C++题解之第458题可怜的小猪
  • 【万字长文】Word2Vec计算详解(三)分层Softmax与负采样
  • 【分布式微服务云原生】探索Dubbo:接口定义语言的多样性与选择
  • SAP将假脱机(Spool requests)内容转换为PDF文档[RSTXPDFT4]
  • DNS能加速游戏吗?
  • Raspberry Pi3B+之C/C++开发环境搭建
  • [笔记] 仿射变换性质的代数证明
  • 遥感影像-语义分割数据集:sar水体数据集详细介绍及训练样本处理流程
  • 极狐GitLab 发布安全补丁版本 17.4.1、17.3.4、17.2.8