【问题标题】:How to know phone operating system IOS or android flutter [duplicate]如何知道手机操作系统IOS或android颤动[重复]
【发布时间】:2021-02-18 23:59:32
【问题描述】:

我尝试通过以下方式了解手机操作系统是否在 Flutter 应用中运行 IOS 或 android:

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

为了在检测到操作系统后设置if条件。我该如何控制这个?有谁知道这个问题的解决方案吗?

【问题讨论】:

标签: flutter


【解决方案1】:
import 'dart:io' show Platform;

if (Platform.isAndroid) {
  // Android-specific code
} else if (Platform.isIOS) {
  // iOS-specific code
}

查看文档:

https://api.flutter.dev/flutter/dart-io/Platform-class.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-09-05
    • 1970-01-01
    • 2014-08-25
    • 1970-01-01
    • 1970-01-01
    • 2012-11-29
    • 2014-03-11
    • 1970-01-01
    相关资源
    最近更新 更多