How do I monitor the clipboard in Flutter?
I want send a notification to user when the user copies an Instagram link in the Instagram app or other apps so the user can download the link in my application ..
For this I need to monitor the clipboard
in android (java) we can use "WatcherService" or use like this:
final ClipboardManager clipboard = (ClipboardManager) this.getSystemService(Context.CLIPBOARD_SERVICE);
clipboard.addPrimaryClipChangedListener( new ClipboardManager.OnPrimaryClipChangedListener() {
public void onPrimaryClipChanged() {
String a = clipboard.getText().toString();
Toast.makeText(getBaseContext(),"Copy:\n"+a,Toast.LENGTH_LONG).show();
}
});
How do I use the services or above code in Flutter?
note: I want it work if the user closes the application
note: The target is more on the Android side