Repository navigation
Open
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: text inputEntering text in a text field or keyboard related problemsEntering text in a text field or keyboard related problemsengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.platform-androidAndroid applications specificallyAndroid applications specificallyteam-androidOwned by Android platform teamOwned by Android platform teamtriaged-androidTriaged by Android platform teamTriaged by Android platform team
Description
I'm developing an app that doesn't really need the clipboard permission, but I can't get rid of the system alert of clipboard reading.
Ways I have tried to fix the problem
- switch to master channel
- run
flutter upgrade - set
enableInteractiveSelectionflag tofalsein TextField widget
Nothing has yet worked on my device nor my friend's
Steps to Reproduce
- Connect a XiaoMi device with MIUI 13 installed
- Execute
flutter debugon the code sample - Copy any text from another place
- Open the debug app just built and the alert pops up
Expected results:
Textfield without reading clipboard
Actual results:
Textfield still reading clipboard everytime it inits
Code sample
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: TextField()
),
);
}
}Flutter doctor
[✓] Flutter (Channel master, 2.13.0-0.0.pre.358, on Ubuntu 20.04.4 LTS
5.11.0-27-generic, locale en_US.UTF-8)
• Flutter version 2.13.0-0.0.pre.358 at /home/linloir/SDK/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision ff08bc4e85 (87 minutes ago), 2022-04-01 10:31:09 -0400
• Engine revision 276261e5d8
• Dart version 2.17.0 (build 2.17.0-263.0.dev)
• DevTools version 2.12.1
• Pub download mirror https://pub.flutter-io.cn
• Flutter download mirror https://storage.flutter-io.cn
[✓] Android toolchain - develop for Android devices (Android SDK version
32.1.0-rc1)
• Android SDK at /home/linloir/Android/Sdk
• Platform android-32, build-tools 32.1.0-rc1
• Java binary at: /snap/android-studio/119/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
• All Android licenses accepted.
[✓] Chrome - develop for the web
• Chrome at google-chrome
[✓] Android Studio (version 2021.1)
• Android Studio at /snap/android-studio/119/android-studio
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
[✓] VS Code (version 1.64.2)
• VS Code at /usr/share/code
• Flutter extension version 3.36.0
[✓] Connected device (2 available)
• M2007J1SC (mobile) • c0063973 • android-arm64 • Android 12 (API 31)
• Chrome (web) • chrome • web-javascript • Google Chrome
98.0.4758.102
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: text inputEntering text in a text field or keyboard related problemsEntering text in a text field or keyboard related problemsengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.platform-androidAndroid applications specificallyAndroid applications specificallyteam-androidOwned by Android platform teamOwned by Android platform teamtriaged-androidTriaged by Android platform teamTriaged by Android platform team

Activity
[-]Flutter reads clipboard on XiaoMi MIUI 13[/-][+]Avoid reading clipboard on XiaoMi MIUI 13[/+]Linloir commentedon Apr 1, 2022
I'm really sorry to post a similar issue to #74139, #85610 and #91591
But after checking the solutions commented in those issues which appears to be the same:
change to master channel and upgrade, nothing has worked for memaheshj01 commentedon Apr 4, 2022
Hi @Linloir, Thanks for filing the issue. Unfortunately none of us on the triage team have a miui 13 to reproduce this issue. We verified on Xiaomi k20 pro (Android 11)
miui 12.5on the latest stable/master channel and the issue was not reproducible. I did try restarting and minimizing the app but it was not reproducible. Labeling this issue for further investigation from the team.Screen.Recording.2022-04-04.at.12.39.17.PM.mov
flutter doctor -v (mac)
[-]Avoid reading clipboard on XiaoMi MIUI 13[/-][+][Android]Avoid clipboard reading permissions on XiaoMi MIUI 13[/+]Linloir commentedon Apr 4, 2022
@maheshmnj Thanks for testing!
It's weird that I also tried this on my friend's RedMiK30P with MIUI 12.5 but it's reproducible.
Therefore I've done some research on this feature (clipboard monitoring) and found out it seems to be available only on Chinese version of MIUI, maybe this causes the problem not reproducible.
NorthSecond commentedon Apr 4, 2022
The divice I use is Xiaomi Redmi K30 pro with miui 12.5 public development version 21.11.3 (Android 11). I succeed in reproducing the problem. When I open this app from the Home screen, the MIUI's security application claims that this app has accessed the clipboard 8 times. (You can find the app behavior record in the
app infointerface).chinmaygarde commentedon Apr 4, 2022
cc @blasten for guidance on whether the out of the box key input interface needs clipboard access by default.
blasten commentedon Apr 4, 2022
maybe related to #85610, and #87678.
cc @justinmc
fzyzcjy commentedon Jul 4, 2023
I can reproduce it in latest Flutter stable: #129931 I am willing to PR to fix it.
4 remaining items
fzyzcjy commentedon Jul 7, 2023
@justinmc Thank you. By the way, if the paste button disappears like that, I (personally) may even think it is a bug not a feature - hey where is my button? ;)
So, shall I (am I allowed to) make a PR to make it "always show the paste button"? As you said, that will be much easier to PR
justinmc commentedon Jan 8, 2024
If this is affecting many people then it makes sense to always show Paste on Android for now. Otherwise we should look at hasPrimaryClip.
ratiger commentedon Feb 6, 2024
the same problem. seemed like invokeMethod 'Clipboard.hasStrings' in xiaomi would show the warning dialog.
LYFhub commentedon Feb 8, 2024
May I know any updates for this topic? Thanks.
alicelifengmei commentedon Aug 19, 2024
I’m dealing with the same issue, I’ve been told that we can’t keep reading clipboard content too often, or the app might get taken down
bleroux commentedon Aug 21, 2024
@justinmc
In #101196 (comment), you gave direction to address this issue:
Looking at the engine code it seems that
hasPrimaryClipsupport was implemented some years ago in flutter-team-archive/engine#27215 on the engine side and in #87678 for the framework side.It does not help to fix the issue because
hasPrimaryClipwill usually return true (having an empty clipboard is probably rare).Do you think we should proceed with "always show Paste on Android for now"?
Morris-Mao commentedon Sep 24, 2024
Flutter 3.16.6 same issue . dozens of time per second。
java.lang.Exception at android.content.ClipboardManager.getPrimaryClipDescription(Native Method) at io.flutter.plugin.platform.PlatformPlugin.clipboardHasStrings(PlatformPlugin.java:555) at io.flutter.plugin.platform.PlatformPlugin.access$1200(PlatformPlugin.java:31) at io.flutter.plugin.platform.PlatformPlugin$1.clipboardHasStrings(PlatformPlugin.java:144) at io.flutter.embedding.engine.systemchannels.PlatformChannel$1.onMethodCall(PlatformChannel.java:184) at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267) at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295) at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:322) at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:257) at android.app.ActivityThread.main(ActivityThread.java:8246) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:626) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1031)justinmc commentedon Sep 25, 2024
@bleroux Why exactly is this still a problem if we are using hasPrimaryClip now? Do XiaoMi devices still show the dialog even when hasPrimaryClip is called? If that's true then I'm on board with just always showing Paste on Android.
I would think it should work and not show the dialog now though. On the framework side hasStrings is used to decide to show Paste or not, and in the engine with flutter-team-archive/engine#27215 it looks like that should only call hasPrimaryClip now.
bleroux commentedon Sep 25, 2024
@justinmc Unfortunately I don't have such a device to look more closely.
I came to this issue because of some recent reports (#153750 and #153749), and I saw that some comments above are somewhat recent (2024).
Yes you're right. I looked more closely at the code. At first I thought that
hasStringswas just returning true when there is something in the clipboard and then that a call togetClipboardDatawas made to see if the content is a text. But I was wrong,getPrimaryClipDescriptionis called to get this information and it is not supposed to trigger any security concerns (based on https://developer.android.com/develop/ui/views/touch-and-input/copy-paste#PastingSystemNotifications).It looks like, on some devices, there is another layer of security which flags those calls to
hasPrimaryClipand/orgetPrimaryClipDescription.Ideally, it would be great to see what happens if a we create a native Android app that calls
hasPrimaryClipandgetPrimaryClipDescriptionmany times. My bet is that the warning would be the same of those devices.Not sure how to proceed. Would it make sense to always show 'Paste' to accomodate those devices security check? This will apply to all devices, not sure about the impact for end users seeing a paste button when there no valid content to paste.
For reference:
clipboardHasStringsgetClipboardDataThinkMars commentedon Dec 13, 2025
Can we remove the loop call 'getPrimaryClipDescription' from didUpdateWidget, as it may cause permission misjudgment and compliance issues on certain platforms.
For this i create a PR: #179840
fix: resolve excessive clipboard checks in TextField (flutter#101196)