我正在寻找一种方法来检测我的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
有办法吗?
谢谢。