0

I need to optimize a Flutter App for Samsung DeX, without changing the behavior of the app, when is running on a normal Smartphone or Tablet. So my question is, is it possible to detect if an App is running in a Desktop Mode from an Android Device like Samsung DeX?

I already tried using the width of the screen, but this didn't work out, because of the screens of some tablets.

2 Answers2

0

It might help, you can try using the 'Platform.isDesktop' property to check if the app is running in desktop mode.

import 'dart:io' show Platform;

if (Platform.isDesktop) {
  // Running in desktop mode
} else {
  // Running in mobile mode
}

This can be useful for adapting your app's behavior to different screen sizes and input methods.

Dima C
  • 39
  • 9
  • My Platform class from dart:io only contains the following detections: Platform.isAndroid Platform.isFuchsia Platform.isIOS Platform.isLinux Platform.isMacOS Platform.isWindows – linusser Jan 30 '23 at 09:07
  • In that case, you can try the Window.physicalSize property to detect if the app is running in desktop mode. if (Window.physicalSize.width > 1000) { // Running in desktop mode } else { // Running in mobile mode } – Dima C Jan 30 '23 at 09:12
0

You need use native Android api. In Java/Kotlin, call UiModeManager.getCurrentModeType()(doc). The desktop mode have value 2, which is UI_MODE_TYPE_DESK(doc)

Update: I found a plugin for this: flutter_ui_mode_manager. You can use FlutterUiModeManager.getDeviceUiMode and look for UiMode.UI_MODE_TYPE_DESK