remote_controller_identifier

Last updated:

0 purchases

remote_controller_identifier Image
remote_controller_identifier Images
Add to Cart

Description:

remote controller identifier

remote_controller_identifier #
A new Flutter plugin project.
Getting Started #
Installation #

Add the latest version of package to your pubspec.yaml (and rundart pub get):

dependencies:
remote_controller_identifier: ^0.0.1
copied to clipboard

Import the package and use it in your Flutter App.

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:lottie/lottie.dart';
import 'package:remote_controller_identifier/remote_controller_identifier.dart';

void main() {
runApp(const MyApp());
}

class MyApp extends StatefulWidget {
const MyApp({super.key});

@override
State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
String _platformVersion = 'Unknown';
final _remoteControllerIdentifierPlugin = RemoteControllerIdentifier();

late String _remoteControllerAppName = "";
late bool isRemoteAppRunning = false;

List<String> packageNames = [
'com.teamviewer.teamviewer.market.mobile',
'com.anydesk.anydeskandroid',
'com.anydesk.adcontrol.ad1',
'com.microsoft.rdc.android',
'com.microsoft.rdc',
'com.google.chromeremotedesktop',
'com.splashtop.remote',
'com.remotepc.client',
'com.realvnc.viewer.android',
'com.logmein.ignitionpro.android',
'com.uptodown.remotecontrol',
'com.paretologic.antitheft',
'com.apowersoft.remoteviewer',
'com.bomgar.ios',
'com.zoho.assist',
'com.splashtop.remote.pad',
'com.supremocontrol',
'com.dameware.mini.remotecontrol',
'com.pd7l.wifimouse',
'com.Banamalon.RemoteControl',
'com.lite.remoteapp',
'com.teamviewer.teamviewer',
'com.nexlink.screenstream'
];

Future<void> findRemoteAppIsRunning(
{required String? appName,
required String? appPackageName,
required String? isEnabled}) async {
final bool? isRunning =
await _remoteControllerIdentifierPlugin.getScreenMirroring();
if (kDebugMode) {
print(
"findRemoteAppIsRunning==> $appName is ${isRunning == true ? 'Running' : 'Disabled'}");
}
setState(() {
isRemoteAppRunning = isRunning!;
_remoteControllerAppName = appName!;
});
}

Future<void> _GetPackageInfo() async {
for (String packageName in packageNames) {
try {
final Map? result =
await _remoteControllerIdentifierPlugin.getPackageInfo(packageName);
if (kDebugMode) {
print("Package data===>$result");
}
if (result != null && result.isNotEmpty) {
final String? appName = result['appName'] as String?;
final String? appPackageName = result['appPackageName'] as String?;
final String isEnabled = result['isEnabled'].toString();
final String? name = result['name'] as String?;
if (appName != null &&
appName.isNotEmpty &&
appPackageName != null &&
appPackageName.isNotEmpty) {
if (kDebugMode) {
print(
'App Name: $appName, Package Name: $appPackageName, Is Enabled: $isEnabled, Name: $name');
}
findRemoteAppIsRunning(
appName: appName,
appPackageName: appPackageName,
isEnabled: isEnabled);
}
break;
} else {
// Handle case when result is null
}
} on PlatformException {
// Handle PlatformException
}
}
}

@override
void initState() {
super.initState();
_GetPackageInfo();
initPlatformState();
}

// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async {
String platformVersion;
// Platform messages may fail, so we use a try/catch PlatformException.
// We also handle the message potentially returning null.
try {
platformVersion =
await _remoteControllerIdentifierPlugin.getPlatformVersion() ??
'Unknown platform version';
} on PlatformException {
platformVersion = 'Failed to get platform version.';
}

// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
if (!mounted) return;

setState(() {
_platformVersion = platformVersion;
});
}

@override
Widget build(BuildContext context) {
_GetPackageInfo();
initPlatformState();
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AppBar(
title: const Text("Remote Control Identifier"),
centerTitle: true,
),
body: SafeArea(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Lottie.asset("assets/assets.json"),
const SizedBox(
height: 5.0,
),
Text(isRemoteAppRunning
? 'This app does not allow remote control.'
: 'Running on: $_platformVersion'),
const SizedBox(
height: 5.0,
),
isRemoteAppRunning
? Text.rich(
textAlign: TextAlign.center,
TextSpan(
children: [
const TextSpan(
text: 'You\'re trying to access this app using ',
style: TextStyle(
color: Colors.redAccent,
fontWeight: FontWeight.w600),
),
TextSpan(
text: _remoteControllerAppName,
style: TextStyle(
color: Colors.redAccent,
fontWeight: FontWeight.w900,
textBaseline: TextBaseline.ideographic,
decoration: TextDecoration.underline,
decorationColor: Theme.of(context)
.textTheme
.titleLarge!
.color),
),
const TextSpan(
text: '. Please disconnect and continue!',
style: TextStyle(
color: Colors.redAccent,
fontWeight: FontWeight.w600),
),
],
),
)
: const SizedBox(
height: 0.0,
width: 0.0,
),
],
),
),
),
),
);
}
}

copied to clipboard
This project is a starting point for a Flutter
plug-in package,
a specialized package that includes platform-specific implementation code for
Android and/or iOS.
For help getting started with Flutter development, view the
online documentation, which offers tutorials,
samples, guidance on mobile development, and a full API reference.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.