This document describes the Flutter-based user interface layer of RustDesk, which serves as the primary cross-platform UI for both desktop (Windows, macOS, Linux) and mobile (Android, iOS) platforms. The Flutter application provides the client-side interface for initiating remote connections, managing peers, configuring settings, and handling incoming server connections.
For details on specific subsystems:
The Flutter application follows a layered architecture with clear separation between UI, business logic, and native Rust core communication. The application supports both desktop and mobile platforms through conditional compilation and platform-specific UI implementations.
Flutter Application Layered Architecture
Sources: flutter/lib/main.dart40-120 flutter/lib/models/model.dart110-178 flutter/lib/common.dart1-50
The Flutter application has multiple entry points depending on the platform and window type. All entry points are defined in main.dart.
| Entry Function | Platform | Purpose | Window Type |
|---|---|---|---|
main() | All | Initial entry point, parses arguments | - |
runMobileApp() | Mobile | Single-window mobile app | Main |
runMainApp(bool) | Desktop | Main window with tabs | Main |
runMultiWindow() | Desktop | Secondary windows | Remote/FileTransfer/etc |
runConnectionManagerScreen() | Desktop | CM window (--cm flag) | CM |
runInstallPage() | Desktop | Installer UI | Install |
Application Initialization Flow
Sources: flutter/lib/main.dart40-120 flutter/lib/main.dart135-178 flutter/lib/main.dart180-190 flutter/lib/main.dart192-287
Desktop applications support multiple window types through the desktop_multi_window package:
DesktopType.main): Primary window with connection page, settings, and tabsDesktopType.remote): Secondary windows for remote sessionsDesktopType.fileTransfer): File transfer UIDesktopType.viewCamera): Camera view windowsDesktopType.portForward): Port forwarding UIDesktopType.terminal): Terminal session windowsDesktopType.cm): CM process window (--cm)Sources: flutter/lib/common.dart105-113 flutter/lib/main.dart52-103 flutter/lib/consts.dart40-50
The FFI class is the central orchestrator for each remote session. Each connection creates its own FFI instance that manages the session lifecycle, models, and communication with Rust.
Sources: flutter/lib/models/model.dart1584-1663 flutter/lib/models/model.dart1665-1750
The FfiModel manages peer information, permissions, connection state, and serves as the event handler for messages from the Rust core.
Key Responsibilities:
PeerInfo)startEventListener()Event Handling Pattern:
Sources: flutter/lib/models/model.dart110-243 flutter/lib/models/model.dart326-483
RustDesk Flutter uses a hybrid state management approach:
| Pattern | Library | Usage |
|---|---|---|
| GetX | get | Global state, reactive variables (Rx*), dependency injection |
| Provider | provider | Scoped state, ChangeNotifier models |
| Obx | get | Reactive UI rebuilds for Rx* variables |
| StatefulWidget | Flutter | Local component state |
Common Reactive Types:
RxBool - Boolean values (e.g., collapse.obs, hide.obs)RxString - String values (e.g., peer labels)RxInt - Integer values (e.g., connection counts)RxList - Observable listsRx<T> - Generic observable wrapperSources: flutter/lib/common.dart21-26 flutter/lib/desktop/widgets/remote_toolbar.dart32-56 flutter/lib/models/state_model.dart1-143
Desktop platforms use a multi-window tabbed interface with complex navigation and window management.
Desktop Application Structure
Sources: flutter/lib/desktop/pages/desktop_home_page.dart29-72 flutter/lib/desktop/pages/connection_page.dart191-326 flutter/lib/desktop/widgets/remote_toolbar.dart228-248
The DesktopTabController manages multiple tabs within desktop windows using GetX for reactive state.
Key Methods:
| Method | Purpose |
|---|---|
add(TabInfo) | Add new tab or jump to existing |
remove(int) | Remove tab by index |
jumpTo(int) | Switch to tab by index |
jumpToByKey(String) | Switch to tab by peer ID |
closeBy(String) | Close tab by key |
widget(String) | Get widget for tab key |
Tab Types by DesktopTabType:
Sources: flutter/lib/desktop/widgets/tabbar_widget.dart95-221 flutter/lib/desktop/widgets/tabbar_widget.dart50-59
The desktop RemotePage is a stateful widget that manages a single remote session with toolbar, input handling, and canvas rendering.
Desktop RemotePage Lifecycle:
Sources: flutter/lib/desktop/pages/remote_page.dart34-73 flutter/lib/desktop/pages/remote_page.dart118-181 flutter/lib/desktop/pages/remote_page.dart307-344
The desktop settings page uses a sidebar tab navigation pattern with multiple setting categories.
Settings Structure:
DesktopSettingPage
├── Tab Navigation (Left, 200px)
│ ├── General
│ ├── Security (if not disabled)
│ ├── Network (if not disabled)
│ ├── Display
│ ├── Plugin (if enabled)
│ ├── Account (if not disabled)
│ ├── Printer (Windows only)
│ └── About
└── Content Area (Right, PageView)
├── _General widget
├── _Safety widget
├── _Network widget
├── _Display widget
├── _Plugin widget
├── _Account widget
├── _Printer widget
└── _About widget
Sources: flutter/lib/desktop/pages/desktop_setting_page.dart64-112 flutter/lib/desktop/pages/desktop_setting_page.dart179-251
Mobile platforms use a bottom navigation bar with single-window navigation and gesture-based input.
Mobile Application Structure
Sources: flutter/lib/mobile/pages/home_page.dart1-100 flutter/lib/mobile/pages/remote_page.dart44-91
The mobile RemotePage handles touch input, soft keyboard management, and gesture recognition for remote control.
Key Features:
Touch Input Flow:
Sources: flutter/lib/mobile/pages/remote_page.dart93-155 flutter/lib/common/widgets/gestures.dart13-23
Mobile platforms require special handling for virtual keyboard input with platform-specific workarounds.
Keyboard Input Processing:
| Platform | Handler | Notes |
|---|---|---|
| iOS | _handleIOSSoftKeyboardInput() | Composing range tracking, backspace handling |
| Android | _handleNonIOSSoftKeyboardInput() | Clipboard detection, paired character handling |
iOS Keyboard Workaround: After virtual keyboard is hidden, physical keyboard input fails. A timer-based workaround unfocuses and refocuses the node.
Sources: flutter/lib/mobile/pages/remote_page.dart240-288 flutter/lib/mobile/pages/remote_page.dart290-338 flutter/lib/mobile/pages/remote_page.dart203-238
The Flutter application communicates with the Rust core through a Foreign Function Interface (FFI) bridge generated by flutter_rust_bridge.
FFI Communication Architecture:
Common FFI Call Categories:
| Prefix | Purpose | Example |
|---|---|---|
session_* | Session operations | session_start(), session_send_mouse() |
main_* | Main app operations | main_get_option(), main_set_option() |
cm_* | Connection manager | cm_get_clients_state() |
peer_* | Peer operations | peer_get_option() |
Sources: flutter/lib/models/platform_model.dart28-87 flutter/lib/models/model.dart326-483
The Rust core emits events that are received by the Flutter app through a callback mechanism. The FfiModel.startEventListener() method registers handlers for 40+ event types.
Common Event Types:
| Event Name | Purpose | Handled By |
|---|---|---|
peer_info | Initial peer information | handlePeerInfo() |
cursor_data | Remote cursor bitmap | handleCursorData() |
cursor_position | Cursor movement | cursorModel.updateCursorPosition() |
permission | Permission changes | updatePermission() |
msgbox | Dialog messages | handleMsgBox() |
clipboard | Clipboard sync | Direct clipboard update |
file_dir | File listing | fileModel.receiveFileDir() |
chat_* | Chat messages | chatModel.receive() |
Sources: flutter/lib/models/model.dart326-483
The Flutter application adapts to platform differences through conditional compilation and runtime checks.
Sources: flutter/lib/common.dart53-64
| Platform | Main Widget | Navigation | Window Management |
|---|---|---|---|
| Desktop | DesktopHomePage | Tabs + multi-window | window_manager, desktop_multi_window |
| Mobile | HomePage | Bottom navigation bar | Single window |
| Web | HomePage | Bottom navigation bar | Browser window |
| Feature | Desktop | Mobile | Notes |
|---|---|---|---|
| Multi-window | ✓ | ✗ | Desktop supports multiple session windows |
| Tabs | ✓ | ✗ | Desktop uses tabbed interface |
| Touch gestures | Limited | ✓ | Mobile has rich gesture support |
| Soft keyboard | ✗ | ✓ | Mobile handles virtual keyboard |
| Toolbar position | Top | Bottom | Different placement |
| Window controls | ✓ | ✗ | Minimize, maximize, close buttons |
| System tray | ✓ | ✗ | Desktop can minimize to tray |
| Background service | Limited | ✓ | Mobile supports background operation |
Sources: flutter/lib/desktop/pages/desktop_home_page.dart29-188 flutter/lib/mobile/pages/home_page.dart1-100
The RemoteToolbar provides session controls for remote desktop sessions on desktop platforms. It supports pinning, collapsing, and auto-hide behavior.
Toolbar State Management:
Toolbar Actions:
Sources: flutter/lib/desktop/widgets/remote_toolbar.dart31-113 flutter/lib/desktop/widgets/remote_toolbar.dart228-248
The canvas rendering system handles display scaling, scrolling, and cursor positioning.
CanvasModel Responsibilities:
ViewStyle Types:
kRemoteViewStyleOriginal: 1:1 pixel mappingkRemoteViewStyleAdaptive: Scale to fit windowkRemoteViewStyleCustom: User-defined scale percentageSources: flutter/lib/models/model.dart2288-2500
The InputModel handles all input events (mouse, keyboard, touch) and translates them to commands for the Rust core.
Input Handling Components:
Relative Mouse Mode (Desktop):
When enabled, the cursor is hidden and locked to the window center. Mouse movement is sent as relative deltas, useful for FPS games and CAD applications. Exited via Ctrl+Alt (Windows/Linux) or Cmd+G (macOS).
Sources: flutter/lib/models/input_model.dart257-350 flutter/lib/models/relative_mouse_model.dart1-100
The OverlayDialogManager manages modal dialogs and overlays using Flutter's overlay system.
Dialog Methods:
show(): Display custom dialogshowLoading(): Show loading spinner with optional canceldismissAll(): Close all dialogsdismissByTag(): Close specific dialog by tagMobile Actions Overlay: The mobile platform shows a floating overlay with Android-style navigation buttons (Back, Home, Recent Apps) when connected to Android peers.
Sources: flutter/lib/common.dart777-971
The StateGlobal singleton manages application-wide state:
Sources: flutter/lib/models/state_model.dart10-143
initEnv(appType)
platformFFIApp() with routingSources: flutter/lib/main.dart122-133 flutter/lib/main.dart135-178
FFI(sessionId)ffi.start(peerId, password)ImageModel.addCallbackOnFirstImage() triggeredffi.close(), cleanup modelsSources: flutter/lib/models/model.dart1665-1750 flutter/lib/desktop/pages/remote_page.dart118-181
The Flutter application provides a comprehensive cross-platform UI layer that:
The architecture emphasizes separation of concerns with clear boundaries between UI widgets, business logic models, and native Rust communication, enabling maintainable cross-platform development.
Refresh this wiki
This wiki was recently refreshed. Please wait 2 days to refresh again.