【问题标题】:Flutter Web, Error: Unsupported operation: Platform._operatingSystem at Object.throw_ [as throw]Flutter Web,错误:不支持的操作:Platform._operatingSystem at Object.throw_ [as throw]
【发布时间】:2020-06-09 18:45:06
【问题描述】:

我尝试使用 firebase auth 和 firebase firestore 构建一个颤振网页。在部署到 Firebase 托管后,我遇到了一个问题,即我无法登录“被 CORS 请求阻止”。我在线阅读并在flutter channel master上进行了flutter升级,之后即使运行“flutter run -d chrome”也会给我一个不支持的错误。我听说这可能是由 dart:io 导入引起的,但我没有更改之前的任何 pubspec.yaml 依赖项

dependencies:
  flutter:
    sdk: flutter

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  firebase_auth:
  firebase_auth_web:
  cloud_firestore: ^0.13.2
  csv: ^4.0.3
  path_provider: ^1.4.4
  flutter_email_sender: ^2.2.0
  intl: ^0.15.7
  url_launcher: ^5.1.4
  url_launcher_web: ^0.1.0

dev_dependencies:
  flutter_test:
    sdk: flutter

repo 在这里:https://github.com/lewlian/Attendy

【问题讨论】:

  • 嗨@Sean!您能否添加您面临的错误?
  • 查看How to Ask 来改进这个问题。
  • 有一个open GitHub issue 与您的错误有关。你能检查一下是不是这样吗?

标签: flutter google-cloud-firestore firebase-authentication flutter-dependencies


【解决方案1】:

与您的错误相关的GitHub issue 仍处于打开状态。仍在进行中的讨论。

一种解决方法是使用universal_platform,正如此评论中所建议的:

在原生 dart 提供平台检测功能之前,当前的解决方法 网页版

使用 Flutter 包universal_platform

//This will explode on Web
bool isIos = Platform.isIOS;

//This will not :)
bool isIos = UniversalPlatform.isIOS;
bool isWeb = UniversalPlatform.isWeb;

【讨论】:

    猜你喜欢
    • 2021-10-01
    • 2023-03-24
    • 2021-12-23
    • 2020-08-02
    • 2021-05-04
    • 2014-03-10
    • 2019-02-15
    • 1970-01-01
    • 2015-02-16
    相关资源
    最近更新 更多