Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 907 Vote(s) - 3.53 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do you detect the host platform from Dart code?

#21
This custom-created class will help you to detect the platform:


````dart
import 'package:flutter/foundation.dart'
show defaultTargetPlatform, kIsWeb, TargetPlatform;

enum Os {
web,
android,
ios,
macOS,
linux,
windows,
fuchsia,
}

class Platform {
const Platform();

/// Platform is Web.
static bool get isWeb => os == Os.web;

/// Platform is Android.
static bool get isAndroid => os == Os.android;

/// Platform is IOS.
static bool get isIOS => os == Os.ios;

/// Platform is Fuchsia.
static bool get isFuchsia => os == Os.fuchsia;

/// Platform is Linux.
static bool get isLinux => os == Os.linux;

/// Platform is MacOS.
static bool get isMacOS => os == Os.macOS;

/// Platform is Windows.
static bool get isWindows => os == Os.windows;

/// Platform is Android or IOS.
static bool get isMobile => isAndroid || isIOS;

/// Platform is Android or IOS or Fuchsia.
static bool get isFullMobile => isMobile || isFuchsia;

/// Platform is Linux or Windows or MacOS.
static bool get isDesktop => isLinux || isWindows || isMacOS;

/// Getting the os name.
static Os get os {
if (kIsWeb) {
return Os.web;
}
switch (defaultTargetPlatform) {
case TargetPlatform.android:
return Os.android;
case TargetPlatform.iOS:
return Os.ios;
case TargetPlatform.macOS:
return Os.macOS;
case TargetPlatform.windows:
return Os.windows;
case TargetPlatform.fuchsia:
return Os.fuchsia;
case TargetPlatform.linux:
return Os.linux;
}
}
}

````
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through