Skip to content

[Cloud Firestore] Unsupported operation: Platform._operatingSystem #1257

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
odwrotnie opened this issue Oct 15, 2019 · 16 comments
Closed

[Cloud Firestore] Unsupported operation: Platform._operatingSystem #1257

odwrotnie opened this issue Oct 15, 2019 · 16 comments
Labels
platform: web Issues / PRs which are specifically for web. plugin: cloud_firestore type: bug Something isn't working

Comments

@odwrotnie
Copy link

I keep getting this with web-enabled:

══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
The following UnsupportedError was thrown building HomePage(dirty):
Unsupported operation: Platform._operatingSystem

User-created ancestor of the error-causing widget was:
Scaffold org-dartlang-app:///packages/x/main.dart:25:15

@odwrotnie odwrotnie added the type: bug Something isn't working label Oct 15, 2019
@BondarenkoStas
Copy link

BondarenkoStas commented Oct 17, 2019

@odwrotnie Please check flutter/flutter#36126. dart:io Platform is not supported in flutter web. You can use flutter/flutter#36135 to detect it and avoid the exception.
If I didn't understand the exception correctly, can you provide the full log?

@ChrisOwen101
Copy link

ChrisOwen101 commented Oct 22, 2019

This issue is happening because the FlutterFire library uses the dart:io package. It looks like this:
image

Here is the log:

:53237/favicon.ico:1 Failed to load resource: the server responded with a status of 404 (Not Found)
js_primitives.dart:30 ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
js_primitives.dart:30 │ package:dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 246:20  get current
js_primitives.dart:30 │ package:logger/src/printers/pretty_printer.dart 87:53                                 log
js_primitives.dart:30 │ package:logger/src/logger.dart 110:16                                                 log
js_primitives.dart:30 │ package:logger/src/logger.dart 72:5                                                   d
js_primitives.dart:30 │ package:carbon_accounting/main.dart 12:14                                             main$
js_primitives.dart:30 │ package:carbon_accounting/main_web_entrypoint.dart 9:3                                main$
js_primitives.dart:30 │ package:dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 45:50            onValue
js_primitives.dart:30 │ package:dart-sdk/lib/async/zone.dart 1379:54                                          runUnary
js_primitives.dart:30 │ package:dart-sdk/lib/async/future_impl.dart 137:18                                    handleValue
js_primitives.dart:30 │ package:dart-sdk/lib/async/future_impl.dart 678:44                                    handleValueCallback
js_primitives.dart:30 │ package:dart-sdk/lib/async/future_impl.dart 707:32                                    _propagateToListeners
js_primitives.dart:30 │ package:dart-sdk/lib/async/future_impl.dart 387:9                                     callback
js_primitives.dart:30 │ package:dart-sdk/lib/async/schedule_microtask.dart 41:11                              _microtaskLoop
js_primitives.dart:30 │ package:dart-sdk/lib/async/schedule_microtask.dart 50:5                               _startMicrotaskLoop
js_primitives.dart:30 │ package:dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 166:15           <fn>
js_primitives.dart:30 │ 
js_primitives.dart:30 ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
js_primitives.dart:30 │ 🐛 Web
js_primitives.dart:30 └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
js_primitives.dart:30 ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
js_primitives.dart:30 The following UnsupportedError was thrown building MultiProvider:
js_primitives.dart:30 Unsupported operation: Platform._operatingSystem
js_primitives.dart:30 
js_primitives.dart:30 The relevant error-causing widget was:
js_primitives.dart:30   MultiProvider org-dartlang-app:///packages/flutter_bloc/src/multi_repository_provider.dart:63:12
js_primitives.dart:30 
js_primitives.dart:30 When the exception was thrown, this was the stack:
js_primitives.dart:30 package:dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 194:49  throw_
js_primitives.dart:30 package:dart-sdk/lib/_internal/js_dev_runtime/patch/io_patch.dart 239:5               _operatingSystem
js_primitives.dart:30 package:dart-sdk/lib/io/platform_impl.dart 60:40                                      get operatingSystem
js_primitives.dart:30 package:dart-sdk/lib/io/platform.dart 71:45                                           get _operatingSystem
js_primitives.dart:30 package:dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/utils.dart 75:6     get
js_primitives.dart:30 package:dart-sdk/lib/io/platform.dart 139:47                                          get isIOS
js_primitives.dart:30 package:dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/utils.dart 75:6     get
js_primitives.dart:30 package:firebase_core/src/firebase_app.dart 15:16                                     get defaultAppName
js_primitives.dart:30 package:dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/utils.dart 75:6     get
js_primitives.dart:30 package:firebase_core/src/firebase_app.dart 51:57                                     get instance
js_primitives.dart:30 package:dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/utils.dart 75:6     get
js_primitives.dart:30 package:firebase_auth/src/firebase_auth.dart 25:67                                    get instance
js_primitives.dart:30 package:dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/utils.dart 75:6     get
js_primitives.dart:30 package:carbon_accounting/repo/AccountsRepo.dart 9:25                                 new
js_primitives.dart:30 package:carbon_accounting/Web.dart 12:44                                              get accountsRepo
js_primitives.dart:30 package:dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/utils.dart 75:6     get
js_primitives.dart:30 package:carbon_accounting/Web.dart 20:44                                              <fn>
js_primitives.dart:30 package:provider/src/delegate_widget.dart 249:14                                      initDelegate
js_primitives.dart:30 package:provider/src/delegate_widget.dart 118:21                                      [_initDelegate]
js_primitives.dart:30 package:provider/src/delegate_widget.dart 110:5                                       initState
js_primitives.dart:30 package:flutter/src/widgets/framework.dart 4085:58                                    [_firstBuild]
js_primitives.dart:30 package:flutter/src/widgets/framework.dart 3936:5                                     mount
js_primitives.dart:30 package:flutter/src/widgets/framework.dart 3109:13                                    inflateWidget
js_primitives.dart:30 package:flutter/src/widgets/framework.dart 2903:12                                    updateChild
js_primitives.dart:30 package:flutter/src/widgets/framework.dart 3978:16                                    performRebuild
js_primitives.dart:30 package:flutter/src/widgets/framework.dart 3755:5                                     rebuild
js_primitives.dart:30 package:flutter/src/widgets/framework.dart 3941:5                                     [_firstBuild]
js_primitives.dart:30 package:flutter/src/widgets/framework.dart 3936:5                                     mount
js_primitives.dart:30 package:flutter/src/widgets/framework.dart 3109:13                                    inflateWidget
js_primitives.dart:30 package:flutter/src/widgets/framework.dart 2903:12                                    updateChild
js_primitives.dart:30 package:flutter/src/widgets/framework.dart 3978:16                                    performRebuild
js_primitives.dart:30 package:flutter/src/widgets/framework.dart 3755:5                                     rebuild
js_primitives.dart:30 package:flutter/src/widgets/framework.dart 3941:5                                     [_firstBuild]
js_primitives.dart:30 package:flutter/src/widgets/framework.dart 3936:5                                     mount
js_primitives.dart:30 package:flutter/src/widgets/framework.dart 3109:13                                    inflateWidget
js_primitives.dart:30 package:flutter/src/widgets/framework.dart 2903:12                                    updateChild
js_primitives.dart:30 package:flutter/src/widgets/framework.dart 3978:16                                    performRebuild
js_primitives.dart:30 package:flutter/src/widgets/framework.dart 3755:5                                     rebuild
js_primitives.dart:30 package:flutter/src/widgets/framework.dart 3941:5                                     [_firstBuild]
js_primitives.dart:30 package:flutter/src/widgets/framework.dart 3936:5                                     mount
js_primitives.dart:30 package:flutter/src/widgets/framework.dart 3109:13                                    inflateWidget
js_primitives.dart:30 package:flutter/src/widgets/framework.dart 2903:12                                    updateChild
js_primitives.dart:30 package:flutter/src/widgets/binding.dart 1032:16                                      [_rebuild]
js_primitives.dart:30 package:flutter/src/widgets/binding.dart 1003:5                                       mount
js_primitives.dart:30 package:flutter/src/widgets/binding.dart 946:16                                       <fn>
js_primitives.dart:30 package:flutter/src/widgets/framework.dart 2327:19                                    buildScope
js_primitives.dart:30 package:flutter/src/widgets/binding.dart 945:12                                       attachToRenderTree
js_primitives.dart:30 package:flutter/src/widgets/binding.dart 822:24                                       attachRootWidget
js_primitives.dart:30 package:flutter/src/widgets/binding.dart 808:7                                        <fn>
js_primitives.dart:30 package:dart-sdk/lib/_internal/js_dev_runtime/private/isolate_helper.dart 46:17       internalCallback
js_primitives.dart:30 
js_primitives.dart:30 ════════════════════════════════════════════════════════════════════════════════════════════════════
29errors.dart:145 Uncaught Error: Assertion failed: org-dartlang-app:///packages/flutter/src/gestures/converter.dart:132:20
!state.down
is not true
    at Object.throw_ [as throw] (errors.dart:194)
    at Object.assertFailed (errors.dart:24)
    at SyncIterable.new.expand (converter.dart:132)
    at expand.next (<anonymous>)
    at ListQueue.new.addAll (queue.dart:655)
    at binding$5.WidgetsFlutterBinding.new.[_handlePointerDataPacket] (binding.dart:84)
    at _engine.PointerBinding.new.[_onPointerData] (pointer_binding.dart:89)
    at pointer_binding.dart:249
    at HTMLElement.<anonymous> (pointer_binding.dart:173)
DartError @ errors.dart:145
throw_ @ errors.dart:194
assertFailed @ errors.dart:24
expand @ converter.dart:132
addAll @ queue.dart:655
[_handlePointerDataPacket] @ binding.dart:84
[_onPointerData] @ pointer_binding.dart:89
(anonymous) @ pointer_binding.dart:249
(anonymous) @ pointer_binding.dart:173

I've had a search through and this seems to be the offending line:
https://github.com/FirebaseExtended/flutterfire/blob/master/packages/firebase_core/lib/src/firebase_app.dart#L14

It appears it's also used in a selection of other places:
https://github.com/search?q=%22dart%3Aio%22+repo%3AFirebaseExtended%2Fflutterfire&type=Code

@adammesa
Copy link

adammesa commented Nov 4, 2019

+1 to this

I've seen some other tickets that say Firebase for dartlang works on flutter web, but I've already made significant inroads into making my app using the FlutterFire plugins — porting it over would be very time consuming at this point.

This does seem like an issue that would be more reasonable to fix on FlutterFire's end of things.

@srihamat
Copy link

+1 to this.

Oh, yes I face the same issue. At the beginning when selecting flutter, it's because I expected all platform (android/ios and web) can share all common library together from reading document. To separate develop web is time consuming...

@cacianokroth
Copy link

any solutions?

@adeolaex
Copy link

Any way to seperate web options from (Ios/Android).

@ctjlewis
Copy link

Hey everyone,

Please make sure you are on dev branch with flutter channel dev and flutter upgrade.

@adammesa
Copy link

@christiantjl is this the commit that you are referring to? b498372

Because as of right now, being on the dev branch does not solve this FlutterFire issue for me.

@adammesa
Copy link

So! I managed to get my app running (at least no platform exception error out the door), by changing the firebase_core version number to ^0.4.2+1.

How exciting! (although it appears I can't login, with no errors explaining why logging in is not working... I think I may be missing firebase_core_web @hterkelsen but I can't get that added as a dependency yet)

@tomasbaran
Copy link

I'd close this issue since it has nothing to do with the firebase but with the flutter for web. So, it's a duplicate of: flutter/flutter#36126

@Salakar
Copy link
Member

Salakar commented Jul 7, 2020

As @tomasbaran mentioned this issue is not specific to FlutterFire so I'm going to go ahead and close this issue. Having said that, as part of our on-going work for #2582, our Firebase Firestore rework (#2913) has now been merged into master. We'll look at publishing some prereleases in the next few days. Thank you

@Salakar Salakar closed this as completed Jul 7, 2020
@tomasbaran
Copy link

One more note, for all the people who would like this issue to be solved, can you please +1 upvote the issue here: flutter/flutter#36126, where it matters, please?

@janshair
Copy link

janshair commented Jul 9, 2020

A quick workaround

I used this library (https://pub.dev/packages/universal_io) to support Platform._operatingSystem for web.

@tomasbaran
Copy link

which library, @janshair?

@janshair
Copy link

@tomasbaran Sorry, edited my comment now. Its https://pub.dev/packages/universal_io

@tomasbaran
Copy link

I was also able to solve it by universal_io package, however only partially since it doesn't work correctly yet. E.g. At the time of writing, iPad isn't detected as iOS (or iPadOS) but as macOS

See more: dint-dev/universal_io#8 dint-dev/universal_io#9

@firebase firebase locked and limited conversation to collaborators Aug 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
platform: web Issues / PRs which are specifically for web. plugin: cloud_firestore type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests