您的位置:首页 > 健康 > 美食 > 秦皇岛商联网络科技有限公司_私密浏览器怎么看片_百度帐号申请注册_活动营销推广方案

秦皇岛商联网络科技有限公司_私密浏览器怎么看片_百度帐号申请注册_活动营销推广方案

2024/10/7 6:03:32 来源:https://blog.csdn.net/majun2009/article/details/142729469  浏览:    关键词:秦皇岛商联网络科技有限公司_私密浏览器怎么看片_百度帐号申请注册_活动营销推广方案
秦皇岛商联网络科技有限公司_私密浏览器怎么看片_百度帐号申请注册_活动营销推广方案
  • 创建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,),],),),),),);}
}
  • 效果展示

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com