gpt4 book ai didi

Flutter Web 平台检查

转载 作者:行者123 更新时间:2023-12-04 12:58:04 25 4
gpt4 key购买 nike

我试图找到一种方法来查看我的 flutter web 项目正在运行的平台(iOS 或 Android)。当我使用 if (Platform.isIOS) { //do something } ,我面临以下错误:

Error: Unsupported operation: Platform._operatingSystem
at Object.throw_ [as throw] (http://localhost:44159/dart_sdk.js:4334:11)
at Function._operatingSystem (http://localhost:44159/dart_sdk.js:55064:17)
at Function.get operatingSystem [as operatingSystem] (http://localhost:44159/dart_sdk.js:55110:27)
at get _operatingSystem (http://localhost:44159/dart_sdk.js:55023:27)
at Function.desc.get [as _operatingSystem] (http://localhost:44159/dart_sdk.js:4819:15)
at get isIOS (http://localhost:44159/dart_sdk.js:55047:26)
at Function.desc.get [as isIOS] (http://localhost:44159/dart_sdk.js:4819:15)
at http://localhost:44159/packages/itoll/main.dart.lib.js:364:33
at wrapper (http://localhost:44159/dart_sdk.js:59904:30)
at http://localhost:44159/:70:11123
有办法吗?
谢谢。

最佳答案

尝试这样做:

import 'package:flutter/foundation.dart' show kIsWeb;

if (kIsWeb) {
//do something
}

关于Flutter Web 平台检查,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63704551/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com