【发布时间】:2019-10-02 16:30:19
【问题描述】:
我正在玩 web 的颤振,我想知道是否有办法检测它在 web 或移动设备上运行。 就像你可以像这样检测 iOS 或 Android。
if (Theme.of(context).platform == TargetPlatform.iOS)
有人知道吗?
【问题讨论】:
标签: flutter
我正在玩 web 的颤振,我想知道是否有办法检测它在 web 或移动设备上运行。 就像你可以像这样检测 iOS 或 Android。
if (Theme.of(context).platform == TargetPlatform.iOS)
有人知道吗?
【问题讨论】:
标签: flutter
还有一个问题here。
解决办法是使用全局常量if (kIsWeb) {...}
文档:https://api.flutter.dev/flutter/foundation/kIsWeb-constant.html
【讨论】:
旧答案:
Flutter Web 在主 Flutter 的另一个分支中处于预览模式。
我认为当正式发布稳定版本时,您可以使用 Platform.isWeb 之类的东西,而更好的选择是等待或使用 Platform.isWindows 或任何其他 SO。
【讨论】: