rustdesk/flutter/lib/desktop/widgets/utils.dart
fufesou 21b277ea3f flutter_desktop: check remote menu, mid commit
Signed-off-by: fufesou <shuanglongchen@yeah.net>
2022-09-08 19:30:48 -07:00

29 lines
974 B
Dart

import 'package:flutter/material.dart';
import 'package:flutter_hbb/utils/multi_window_manager.dart';
/// Connect to a peer with [id].
/// If [isFileTransfer], starts a session only for file transfer.
/// If [isTcpTunneling], starts a session only for tcp tunneling.
/// If [isRDP], starts a session only for rdp.
void connect(BuildContext context, String id,
{bool isFileTransfer = false,
bool isTcpTunneling = false,
bool isRDP = false}) async {
if (id == '') return;
id = id.replaceAll(' ', '');
assert(!(isFileTransfer && isTcpTunneling && isRDP),
"more than one connect type");
FocusScopeNode currentFocus = FocusScope.of(context);
if (isFileTransfer) {
await rustDeskWinManager.newFileTransfer(id);
} else if (isTcpTunneling || isRDP) {
await rustDeskWinManager.newPortForward(id, isRDP);
} else {
await rustDeskWinManager.newRemoteDesktop(id);
}
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
}