Flutter TextField引起的剪切板合规问题

本文探讨了一次剪贴板监控引发的误触发事件,通过追踪代码发现EditableText组件与ClipboardStatusNotifier的关联,最终定位到初始化问题。作者提供了两种解决方法:修改原生代码或在Flutter插件层面进行干预。

背景

最近突然收到安全部门的消息,说有些页面在获取剪切板内容。我当时很确性的说,我压根没去获取剪切板内容啊。
但是他给出了具体的调用堆栈,这一看果然是真的。

at android.content.ClipboardManager.getPrimaryClip(Native Method) at 
io.flutter.plugin.platform.PlatformPlugin.getClipboardData(PlatformPlugin.java:332) at 
io.flutter.plugin.platform.PlatformPlugin.access$700(PlatformPlugin.java:28) at 
io.flutter.plugin.platform.PlatformPlugin$1.getClipboardData(PlatformPlugin.java:107) at 
io.flutter.embedding.engine.systemchannels.PlatformChannel$1.onMethodCall(PlatformChannel.java:141) at 
io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233) at 
io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85) at 
io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818) at 
android.os.MessageQueue.nativePollOnce(Native Method) at 
android.os.MessageQueue.next(MessageQueue.java:325) at 
android.os.Looper.loop(Looper.java:142) at 
android.app.ActivityThread.main(ActivityThread.java:6549) at java.lang.reflect.Method.invoke(Native 
Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:491) at 
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

找出问题

1.确定是什么原因导致的
根据截图的几个页面,当然他当时截图的页面是不对的,但是这个页面的后一个页面。
我是根据断点原生代码去确定范围的。
发现出现在了地址编辑页,根据经验判断问题出现在了输入框上。
然后我在flutter项目中搜索 Clipboard.getData
在这里插入图片描述
为什么搜索这个也是根据上面的堆栈那确定的

io
评论 17
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值