can't get clipboard data in foeground

37 views Asked by At

I am trying to monitor the clipboard in the foeground by running a check on it every 500 milliseconds but for some reason it's not working...

Timer.periodic(Duration(milliseconds: 500), (timer) async {

    print("Called");

    ClipboardData? currentClip = await Clipboard.getData(Clipboard.kTextPlain);
    print("Called 2");



    if (currentClip?.text != lastClip) {
      print("Clipboard data changed: ${currentClip?.text}");
      flutterLocalPlugin.show(
          90,
          "clipSync",
          "Copied ${DateTime.now()}",
          NotificationDetails(android: AndroidNotificationDetails("clipSync", "clipSync is Running", ongoing: true, icon: "app_icon")));
      socket.emit('copy', currentClip?.text);
      lastClip = currentClip?.text;
    }

 

  });

For some weird reason Called prints but Called 2 doesn't

I tried wrapping it in a try and catch block but I got no error

0

There are 0 answers