Flutter Clipboard return null in android 10 [duplicate]

We should access the clipboard in Window.Callback.onWindowFocusChanged(true), as that is the moment at which web gain input focus, which is required to read the clipboard in Android 10 (Q).

So for access to clipboard we need input focus in onResume.

I changed the code this way and my problem was solved:

@override
  void didChangeAppLifecycleState(AppLifecycleState state) async {
    super.didChangeAppLifecycleState(state);
    switch (state) {
      case AppLifecycleState.resumed:
        FocusScope.of(context).requestFocus(new FocusNode()); // This line added
        ClipboardData data = await Clipboard.getData(Clipboard.kTextPlain);
        print("onResumed __${data}");
        break;
    }
  }

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top