Search code examples
androidflutterwebrtcstreaming

How to tap a button remotely in App1 from App2 in Flutter


I am developing 2 apps (App1 and App2). In App1, I have a button to record screen.

Now my question is, is there any way to tap or run the screen recording options in App1 remotely when I tap on a button in App2 ?

I have no idea how to implement this. Need guidance.


Solution

  • There are numerous ways to do this, but some may be more complicated than others. I assume you are using something like flutter_screen_recording to start the recording on either of the apps.

    1. The easiest would be to create a web server locally on both where one sends the record command while the other listens for it and responds to the other to stop. This would be done through a plugin which starts a background process like workmanager and using localhost. Starting a server on localhost would look like this: var server = await HttpServer.bind(InternetAddress.loopbackIPv4, 8080);

    2. You could use a common database to indicate changes. Hive works well. Then check on the other side for changes using a timer.

    
    'dart:async';
    main() {
      const checkDelay= Duration(milliseconds: 300);
      Timer.periodic(checkDelay, (Timer t) => check());
    }```