flutter和原生利用pigeon建立通道

首先导入依赖:

dependencies:
pigeon: ^10.0.0

image.png

定义一个文件:

/// 用于定于flutter和平台的桥接方法
/// @HostApi() 标记的,是用于 Flutter 调用原生的方法;
/// @FlutterApi() 标记的,是用于原生调用 Flutter 的方法;
/// @async 如果原生的方法,是步回调那种,你就可以使用这个标记;
/// 在项目根目录,运行以下命令生成平台代码
/// dart run pigeon --input pigeons/messages.dartimport 'package:pigeon/pigeon.dart';@ConfigurePigeon(PigeonOptions(dartOut: 'lib/pigeons/pigeon.dart',dartOptions: DartOptions(),// objcHeaderOut: '../isolarCloud/operation4ios/Flutter/SGFlutterBridge.h',// objcSourceOut: '../isolarCloud/operation4ios/Flutter/SGFlutterBridge.m',// objcOptions: ObjcOptions(),kotlinOut:'../iSolarCloud/LibBase/src/main/java/com/isolarcloud/libbase/flutter/SGFlutterBridge.kt',kotlinOptions: KotlinOptions(),
))
class CommonParams {String? pageName;Map<String?, Object?>? arguments;
}
class ApiParams {String? url;Map<String?, Object?>? arguments;
}/// Flutter调用原生的Api,全部放在一个抽象类中即可
@HostApi()abstract class SGHostApi {/// push至原生页面,参数:页面名称、参数void pushNativePage(CommonParams params);/// pop出当前页面,预留参数,可通过params.pageName pop到指定页面void popPage(CommonParams? params);/// 通过Key获取本地化文本数据(同步)String getLocalizedText(String? key);/// Flutter通过URL和arguments调用原生端接口,异步返回数据给Flutter端@asyncMap requestNativeApi(ApiParams apiParams);/// 是否允许开启Native页面的原生手势返回效果void enablePopRecognizer(bool enable);
}

运行命令行:
dart run pigeon --input pigeons/messages.dart

接着可以运行下:flutter pub get 的命令

自动会生成这个文件:

image.png

里面会实现SGHostApi的定义的方法:比如下面的方法就是自动生成:

/// push至原生页面,参数:页面名称、参数
Future<void> pushNativePage(CommonParams arg_params) async {final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>('dev.flutter.pigeon.isolarcloud_flutter.SGHostApi.pushNativePage', codec,binaryMessenger: _binaryMessenger);final List<Object?>? replyList =await channel.send(<Object?>[arg_params]) as List<Object?>?;if (replyList == null) {throw PlatformException(code: 'channel-error',message: 'Unable to establish connection on channel.',);} else if (replyList.length > 1) {throw PlatformException(code: replyList[0]! as String,message: replyList[1] as String?,details: replyList[2],);} else {return;}
}

注意打开这个代码注释:意思是在你Android项目的某个路径下生成SGFlutterBridge文件。

kotlinOut:'../iSolarCloud/LibBase/src/main/java/com/isolarcloud/flutter/SGFlutterBridge.kt',
kotlinOptions: KotlinOptions(),

然后会在:上面这个路径下自动生成和原生的桥接方法,这里执行的是Android的方法,ios只需要打开:

  // objcHeaderOut: '../isolarCloud/operation4ios/Flutter/SGFlutterBridge.h',// objcSourceOut: '../isolarCloud/operation4ios/Flutter/SGFlutterBridge.m',// objcOptions: ObjcOptions(),

我们先看看原生和flutter项目的依赖:

image.png

在Android的项目settings.gradle中配置引用:

setBinding(new Binding([gradle: this]))
evaluate(new File(settingsDir,'../isolarcloud_flutter/.android/include_flutter.groovy')
)

以上操作就把两个项目关联在一起了。下面是自动生成的桥接方法,pigeon自动帮你实现:

/*** Flutter调用原生的Api,全部放在一个抽象类中即可** Generated interface from Pigeon that represents a handler of messages from Flutter.*/
interface SGHostApi {/** push至原生页面,参数:页面名称、参数 */fun pushNativePage(params: CommonParams)/** pop出当前页面,预留参数,可通过params.pageName pop到指定页面 */fun popPage(params: CommonParams?)/** Flutter通过URL和arguments调用原生端接口,异步返回数据给Flutter端 */fun requestNativeApi(apiParams: ApiParams, callback: (Result<String?>) -> Unit)/** 是否允许开启Native页面的原生手势返回效果 */fun enablePopRecognizer(enable: Boolean)/*** 调用原生toast* type:0 老版,1:国内,2:海外样式*/fun showToast(type: AppType, msg: String)/*** 调用原生toast* type:0 老版,1:国内,2:海外样式*/fun showLoading(show: Boolean, type: AppType, msg: String?)/** 获取用户信息 */fun getUserInfo(): String?companion object {/** The codec used by SGHostApi. */val codec: MessageCodec<Any?> by lazy {SGHostApiCodec}/** Sets up an instance of `SGHostApi` to handle messages through the `binaryMessenger`. */@Suppress("UNCHECKED_CAST")fun setUp(binaryMessenger: BinaryMessenger, api: SGHostApi?) {run {val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.isolarcloud_flutter.SGHostApi.pushNativePage", codec)if (api != null) {channel.setMessageHandler { message, reply ->val args = message as List<Any?>val paramsArg = args[0] as CommonParamsvar wrapped: List<Any?>try {api.pushNativePage(paramsArg)wrapped = listOf<Any?>(null)} catch (exception: Throwable) {wrapped = wrapError(exception)}reply.reply(wrapped)}} else {channel.setMessageHandler(null)}}run {val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.isolarcloud_flutter.SGHostApi.popPage", codec)if (api != null) {channel.setMessageHandler { message, reply ->val args = message as List<Any?>val paramsArg = args[0] as CommonParams?var wrapped: List<Any?>try {api.popPage(paramsArg)wrapped = listOf<Any?>(null)} catch (exception: Throwable) {wrapped = wrapError(exception)}reply.reply(wrapped)}} else {channel.setMessageHandler(null)}}run {val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.isolarcloud_flutter.SGHostApi.requestNativeApi", codec)if (api != null) {channel.setMessageHandler { message, reply ->val args = message as List<Any?>val apiParamsArg = args[0] as ApiParamsapi.requestNativeApi(apiParamsArg) { result: Result<String?> ->val error = result.exceptionOrNull()if (error != null) {reply.reply(wrapError(error))} else {val data = result.getOrNull()reply.reply(wrapResult(data))}}}} else {channel.setMessageHandler(null)}}run {val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.isolarcloud_flutter.SGHostApi.enablePopRecognizer", codec)if (api != null) {channel.setMessageHandler { message, reply ->val args = message as List<Any?>val enableArg = args[0] as Booleanvar wrapped: List<Any?>try {api.enablePopRecognizer(enableArg)wrapped = listOf<Any?>(null)} catch (exception: Throwable) {wrapped = wrapError(exception)}reply.reply(wrapped)}} else {channel.setMessageHandler(null)}}run {val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.isolarcloud_flutter.SGHostApi.showToast", codec)if (api != null) {channel.setMessageHandler { message, reply ->val args = message as List<Any?>val typeArg = AppType.ofRaw(args[0] as Int)!!val msgArg = args[1] as Stringvar wrapped: List<Any?>try {api.showToast(typeArg, msgArg)wrapped = listOf<Any?>(null)} catch (exception: Throwable) {wrapped = wrapError(exception)}reply.reply(wrapped)}} else {channel.setMessageHandler(null)}}run {val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.isolarcloud_flutter.SGHostApi.showLoading", codec)if (api != null) {channel.setMessageHandler { message, reply ->val args = message as List<Any?>val showArg = args[0] as Booleanval typeArg = AppType.ofRaw(args[1] as Int)!!val msgArg = args[2] as String?var wrapped: List<Any?>try {api.showLoading(showArg, typeArg, msgArg)wrapped = listOf<Any?>(null)} catch (exception: Throwable) {wrapped = wrapError(exception)}reply.reply(wrapped)}} else {channel.setMessageHandler(null)}}run {val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.isolarcloud_flutter.SGHostApi.getUserInfo", codec)if (api != null) {channel.setMessageHandler { _, reply ->var wrapped: List<Any?>try {wrapped = listOf<Any?>(api.getUserInfo())} catch (exception: Throwable) {wrapped = wrapError(exception)}reply.reply(wrapped)}} else {channel.setMessageHandler(null)}}}}
}

同步或者异步的去调用自动生成的方法:

Future<void> makeApiCall() async {var arguments = {"curPage": 1, "size": 10, "message_scene_code": 2};final stopwatch = Stopwatch()..start();await SGHostApi().requestNativeApi(ApiParams(arguments: arguments)).then((value) {print("数据回来的时间:${DateTime.now().millisecondsSinceEpoch}");stopwatch.stop();print("总共花费时间:${stopwatch.elapsedMilliseconds}毫秒");toast = "android 返回的数据==$value";// print("value===$value");setState(() {});});
}_getString(){SGHostApi().getLocalizedText("I18N_COMMON_SERVICE_AGREEMENT_DESCRIPTION").then((value){print("android 给过来的数据==$value");});setState(() {});
}

Android的代码:

class SingleFlutterActivity : FlutterActivity(), EngineBindingsDelegate {private val engineBindings: EngineBindings by lazy {EngineBindings(activity = this, delegate = this, entrypoint = FlutterRouter.DEMO_ENTRY_POINTER, initialRoute = "${FlutterRouter.DEMO_ROUTER}?psId=1234")}override fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)engineBindings.attach()/*** flutter 调用原生的方法* */SGHostApiget.setUp(getFlutterEngine()!!.getDartExecutor().getBinaryMessenger(), MyApi())SGHostApi.setUp(getFlutterEngine()!!.getDartExecutor().getBinaryMessenger(),FlutterToNativeApi() )}override fun onDestroy() {super.onDestroy()engineBindings.detach()}override fun provideFlutterEngine(context: Context): FlutterEngine? {return engineBindings.engine}override fun onNext() {val flutterIntent = Intent(this, LoginActivity::class.java)startActivity(flutterIntent)}/*** flutter 调用原生的方法,原生写法* */override fun onNext(str: String?) {val flutterIntent = Intent(this, FlutterToAndroidActivity::class.java)flutterIntent.putExtra("extraString", str)startActivity(flutterIntent)}/*** flutter 调用原生的方法* */class MyApi : SGHostApiget {override fun getString(): String {println("测试===6666")return "测试===6666,这里是Android的方法"}}/*** flutter 调用原生的方法* */class FlutterToNativeApi() : SGHostApi {/*** flutter调用原生跳原生页面* */override fun pushNativePage(params: CommonParams) {//params.pageName 页面名称非类名,不可直接创建实例/*val flutterIntent = Intent(this, params::class.java)flutterIntent.putExtra("extraString", str)startActivity(flutterIntent)*/}/*** flutter调用原生跳原生页面* */override fun popPage(params: CommonParams?) {//flutter调用Android去退出页面}/*** flutter调用原生 获取国际化字符串* */override fun getLocalizedText(key: String?): String {return I18nUtil.getString(key);}/*** flutter调用原生 获取网络信息 异步* */override fun requestNativeApi(apiParams: ApiParams,callback: (Result<Map<Any, Any?>>) -> Unit,) {/*val bitmap: Bitmap = BitmapFactory.decodeResource(BaseApplication.getApplication().resources, R.drawable.test_image)val outputStream: ByteArrayOutputStream = ByteArrayOutputStream()bitmap.compress(Bitmap.CompressFormat.PNG, 50, outputStream)val size: Int = outputStream.size()println("字节大小: $size")val result: Result<Map<Any, Any?>> = Result.success(mapOf("name" to outputStream),)callback(result)*/val map: MutableMap<String, Any> = HttpRequest.getCommonParamMap()HttpUtil.postWithPath("/v1/devService/getDevModelUpgradeConfigList", /*apiParams.arguments*/map, object : HttpGlobalHandlerCallback<UpdateRequestBean?>() {override fun onSuccess(jsonResult: JsonResults<UpdateRequestBean?>) {// 处理成功返回的数据val data = jsonResult.result_data // 获取数据if (data is UpdateRequestBean) {data as UpdateRequestBean}println("开始传输时间: ${System.currentTimeMillis()}")callback(Result.success(data!!.toMap())) // 通过callback返回结果// 打印字节大小val byteArray = data?.toString()?.toByteArray(Charsets.UTF_8)val size = byteArray?.size ?: 0println("字节大小: $size")}fun UpdateRequestBean.toMap(): Map<Any, Any?> {val map = mutableMapOf<Any, Any?>()map["code"] = codemap["record"] = recordmap["totalFileSize"] = totalFileSizemap["pageList"] = pageList?.map { fileInfo ->mapOf("file_url" to fileInfo.file_url,"file_signature" to fileInfo.file_signature,"file_name" to fileInfo.file_name,"file_id" to fileInfo.file_id,"dev_model" to fileInfo.dev_model,"file_size" to fileInfo.file_size,"type" to fileInfo.type,"dev_type_id" to fileInfo.dev_type_id,"record_id" to fileInfo.record_id,"sn" to fileInfo.sn,"update_time_stamp" to fileInfo.update_time_stamp,"block_flag" to fileInfo.block_flag)}return map}override fun onError(type: ErrorNetType) {super.onError(type)// 处理错误情况// val result: Result<Map<Any, Any?>> = Result.success(//   mapOf(//     "name" to "John",//     "age" to 30,//     "email" to "john@example.com"//   )// )// callback(result)// 通过callback返回错误信息val failureResult: Result<Map<Any, Any?>> = Result.failure(Exception("An error occurred"))callback(failureResult)}override fun onFinish() {super.onFinish()}})}override fun disablePopRecognizer(disable: Boolean) {}}}

在flutter中统一使用这个类来获取原生获取的网络数据:

/// 成功回调
typedef SuccessCallback = void Function(Map<String, dynamic>? resultData, String resultCode, String resultMsg);/// 失败回调
typedef ErrorCallback = void Function();class RequireNativeApi {static void postWithPathOversea(String? url, Map<String?, Object?>? arguments,SuccessCallback? successCallback, ErrorCallback? errorCallback,{bool showToast = true}) {postWithPath(url, arguments, successCallback, errorCallback,showToast: showToast, appType: AppType.oversea);}static void postWithPathDomestic(String? url,Map<String?, Object?>? arguments,SuccessCallback? successCallback,ErrorCallback? errorCallback,{bool showToast = true}) {postWithPath(url, arguments, successCallback, errorCallback,showToast: showToast, appType: AppType.domestic);}static void postWithPath(String? url, Map<String?, Object?>? arguments,SuccessCallback? successCallback, ErrorCallback? errorCallback,{bool showToast = true, AppType appType = AppType.oversea}) {ApiParams apiParams = ApiParams();apiParams.url = url;apiParams.arguments = arguments;sgApi.requestNativeApi(apiParams).then((data) {debugPrint("");debugPrint("======================================================");debugPrint("api: $url");debugPrint("业务入参: $arguments");debugPrint("出参:$data");debugPrint("======================================================");if (data == null || data.isEmpty) {/// 网络异常if (showToast) {sgApi.showToast(appType, SGi18n.key("I18N_COMMON_NETWORK_ERROR"));}if (errorCallback != null) {errorCallback();}return;}var jsonData = json.decode(data);if (successCallback != null) {// 返回接口返回数据,需要调用各个实体类的方法,所以需要各个业务层将Map转为对应的实体类successCallback(jsonData['result_data'] ?? {},jsonData['result_code'] ?? "",jsonData['result_msg'] ?? "",);}}).onError((error, stackTrace) {debugPrint("RequireNativeApi error: $error");debugPrint("RequireNativeApi error: $stackTrace");if (showToast) {sgApi.showToast(appType, SGi18n.key("I18N_COMMON_NETWORK_ERROR_MESSAGE"));}if (errorCallback != null) {errorCallback();}});}
}

flutter中要使用的地方直接拿到成功和失败的回调即可:

RequireNativeApi.postWithPathOversea(Api.getDeleteUserMessage, argument,getDeleteMessageSuccess, () => SGOSLoadingToast.dismissLoading());

我项目中用的是getx,大家可以看看我完整的代码:

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:isolarcloud_flutter/api/api.dart';
import 'package:isolarcloud_flutter/api/require_native_api.dart';
import 'package:isolarcloud_flutter/bean/home_msg_entity.dart';
import 'package:isolarcloud_flutter/bean/update_msg_entity.dart';
import 'package:isolarcloud_flutter/modules/demo/constant/constant_state_id.dart';
import 'package:isolarcloud_flutter/utils/hud/sg_os_loading_toast.dart';
import 'package:isolarcloud_flutter/utils/json_cache_util.dart';import 'sg_message_first_state.dart';class SGMessageHomePageLogic extends GetxController {final SGMessageHomePageState state = SGMessageHomePageState();static const idMessageClearUpdate = "message_clear_update";static const idMessageList = "message_list";static const idLoadFail = "message_load_fail";void getList(String labelStr, {bool isFirst = false}) async {state.labelStr = labelStr;isFirst ? SGOSLoadingToast.showLoading() : null;Map<String, Object> argument = {};var cache = await JsonCacheManageUtils.getCacheData(JsonCacheManageUtils.HomeMessageResponse,labelId: labelStr.toString()).then((value) {if (value != null) {return HomeMsgEntity.fromJson(value as Map<String, dynamic>);}});state.hasCache = false;if (cache is HomeMsgEntity) {state.pageList = cache;state.hasCache = true;update([idMessageList + labelStr.toString()]);}RequireNativeApi.postWithPathOversea(Api.getHomeMessageList, argument, getHomeMessageSuccess, () {isFirst ? SGOSLoadingToast.dismissLoading() : null;update([idLoadFail]);});}void getHomeMessageSuccess(Map<String, dynamic>? resultData, String resultCode, String resultMsg) {if (resultCode == "1" && resultData != null && resultData.isNotEmpty) {JsonCacheManageUtils.saveCacheData(JsonCacheManageUtils.HomeMessageResponse,labelId: state.labelStr,resultData);state.pageList = HomeMsgEntity.fromJson(resultData);}SGOSLoadingToast.dismissLoading();if (!state.hasCache) {update(["$idMessageList${state.labelStr}"]);}}/// clear 消息 传null为全部void updateUserAllMessage(dynamic messageSceneCode) {SGOSLoadingToast.showLoading();Map<String, dynamic> argument = {"is_all": 1,"message_scene_code": messageSceneCode,};RequireNativeApi.postWithPathOversea(Api.getUpdateUserMessage, argument,getClearMessageSuccess, () => SGOSLoadingToast.dismissLoading());}void getClearMessageSuccess(Map<String, dynamic>? resultData, String resultCode, String resultMsg) {if (resultCode == "1" && resultData != null && resultData.isNotEmpty) {state.updateBean = UpdateMsgEntity.fromJson(resultData);}SGOSLoadingToast.dismissLoading();update([idMessageClearUpdate]);}//删除单个消息大类void deleteUserMessage(String? ids, String? messageSceneCode, int index) {SGOSLoadingToast.showLoading();Map<String, dynamic> argument = {"ids": ids,"message_scene_code": messageSceneCode,};state.removeIndex = index;RequireNativeApi.postWithPathOversea(Api.getDeleteUserMessage, argument,getDeleteMessageSuccess, () => SGOSLoadingToast.dismissLoading());}void getDeleteMessageSuccess(Map<String, dynamic>? resultData, String resultCode, String resultMsg) {debugPrint("resultData: $resultData");if (resultCode == "1" && resultData != null && resultData.isNotEmpty) {state.deleteBean = UpdateMsgEntity.fromJson(resultData);}SGOSLoadingToast.dismissLoading();update([StateListenerId.messageDelete]);}///底部按钮删除全部选中的void deleteCheckMessage(List<HomeMsgPageList> messageHomeList) {SGOSLoadingToast.showLoading();StringBuffer messageSceneCodes = StringBuffer();for (int i = 0; i < messageHomeList.length; i++) {String? sceneCode = messageHomeList[i].messageSceneCode;messageSceneCodes.write(sceneCode);if (i != messageHomeList.length - 1) {messageSceneCodes.write(',');}}String result = messageSceneCodes.toString();if (result.isEmpty) {return;}Map<String, dynamic> argument = {"ids": null,"message_scene_code": result,};RequireNativeApi.postWithPathOversea(Api.getDeleteUserMessage, argument,getDeleteMessageSuccess, () => SGOSLoadingToast.dismissLoading());}
}

按理来说这个GetxController类是用来访问网络的类,这里用来和原生交互,就这样子。

最近工作忙,加班重,疏于思考,缺乏输出,望大家理解,有时间优化文章,敬请期待!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/90256.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

FL studio21.1中文最新版FL萝卜音乐制作软件

FL studio21.1版中文名字叫做水果音乐编曲软件&#xff0c;是一款非常专业的电脑音乐制作软件。全新的21版本在功能上进行了升级&#xff0c;帮助用户来进行编曲、剪辑、录音、混音等多种工作&#xff0c;还可以为用户提供很多音乐创作的灵感&#xff0c;让你制作出各种好听的音…

ioctl、printk及多个此设备支持

一、ioctl操作实现 ioctl&#xff08;Input/Output Control&#xff09;是一个在 Unix-like 操作系统中的系统调用&#xff0c;用于控制设备或文件的各种操作。它允许用户空间程序与内核空间进行交互&#xff0c;执行一些特定的设备控制、状态查询或其他操作&#xff0c;而不必…

c语言每日一练(12)

前言&#xff1a;每日一练系列&#xff0c;每一期都包含5道选择题&#xff0c;2道编程题&#xff0c;博主会尽可能详细地进行讲解&#xff0c;令初学者也能听的清晰。每日一练系列会持续更新&#xff0c;暑假时三天之内必有一更&#xff0c;到了开学之后&#xff0c;将看学业情…

红黑树(AVL树的优化)下(代码实现)

我们先简单的将节点找到要插入的位置&#xff0c;进行前后链接&#xff08;先不进行调整&#xff09; 解决情况一的 &#xff1a; cur为红&#xff0c;parent是红 &#xff0c; grandfater是黑&#xff0c;uncle存在且为红的情况 情况二情况三&#xff1a;

指针的进阶一

目录 1.字符指针 2.数组指针 3.指针数组 4.数组传参 5.函数指针 1.字符指针 int main() { const char* pstr "hello world."; printf("%s\n", pstr); return 0; } pstr中存放的就是字符串的首元素地址&#xff0c;并不是把字符串hello world 放到字符…

Spring Boot 中是使用 JDK Proxy 动态代理还是 CGLib ?

1. Spring Boot 中是使用 JDK Proxy 动态代理还是 CGLib ? 首先我们知道在 Spring 里面&#xff0c;动态代理的底层&#xff0c;默认使用的是 JDK Proxy 代理&#xff0c;这一点在官方文档有具体的说明&#xff1a; 既然 Spring 中的动态代理默认使用 JDK Proxy&#xff0c;那…

C++调用Python Win10 Miniconda虚拟环境配置

目录 前言1. Win10 安装 Miniconda2. 创建虚拟环境3. 配置C调用python环境4. C调用Python带参函数5.遇到的问题6. 总结 前言 本文记录了Win10 系统下Qt 应用程序调用Python时配置Miniconda虚拟环境的过程及遇到的问题&#xff0c;通过配置Python虚拟环境&#xff0c;简化了Qt应…

探索OLED透明屏的优缺点:引领科技未来的革命性突破

OLED透明屏作为一项革命性的创新技术&#xff0c;其令人惊叹的透明度和柔性性能引起了全球范围内的关注。 然而&#xff0c;了解OLED透明屏的优缺点对于我们全面认识其在科技未来中的地位至关重要。 今天&#xff0c;尼伽将深入探讨OLED透明屏的优势和限制&#xff0c;并借助…

Java课题笔记~ 综合案例

3.综合案例 3.1 功能介绍 以上是我们在综合案例要实现的功能。除了对数据的增删改查功能外&#xff0c;还有一些复杂的功能&#xff0c;如 批量删除、分页查询、条件查询 等功能 批量删除 功能&#xff1a;每条数据前都有复选框&#xff0c;当我选中多条数据并点击 批量删除 按…

LeetCode 热题 100(七):105. 从前序与中序遍历序列构造二叉树、14. 二叉树展开为链表

题目一&#xff1a; 105. 从前序与中序遍历序列构造二叉树https://leetcode.cn/problems/construct-binary-tree-from-preorder-and-inorder-traversal/ 思路&#xff1a;依据前序遍历的根左右和中序遍历的左根右&#xff0c; 且根左长度&#xff1d;左根 代码&#xff1a; …

uniapp的 picker 日期时间选择器

效果图&#xff1a; dateTimePicker.js function withData(param){return param < 10 ? 0 param : param; } function getLoopArray(start,end){var start start || 0;var end end || 1;var array [];for (var i start; i < end; i) {array.push(withData(i))…

Flutter:getX的学习

前言 学习教程&#xff1a;Getx教程_FlutterGetx系列实战教程 简介 getX是第三方的状态管理插件&#xff0c;不仅具有状态管理的功能&#xff0c;还具有路由管理、主题管理、国际化多语言管理、网络请求、数据验证等功能。相比其他状态管理组件&#xff0c;getX简单、功能强大…