Skip to content

Conversation

@stefanschaller
Copy link
Collaborator

@stefanschaller stefanschaller commented Mar 5, 2025

Fix #550

Please add the following to the pubspec.yaml to test it in other projects:

dependencies: 
  # vector map
  maplibre_gl:
    git:
      url: https://github.com/maplibre/flutter-maplibre-gl.git
      ref: 550-bug-unsupported-operation-platform_operatingsystem
      path: maplibre_gl

dependency_overrides:
  maplibre_gl_platform_interface:
    git:
      url: https://github.com/maplibre/flutter-maplibre-gl.git
      ref: 550-bug-unsupported-operation-platform_operatingsystem
      path: maplibre_gl_platform_interface

@stefanschaller stefanschaller linked an issue Mar 5, 2025 that may be closed by this pull request
@albertmoravec
Copy link
Contributor

albertmoravec commented Mar 25, 2025

I get that dart:io sucks, but please consider if it is necessary to import new package for a single if-statement where kIsWeb check would be enough. If it is planned to be used further then of course it's not an issue.

For end users though this would add an additional version constraint on universal_platform and prevent them from upgrading to newer major version in the future unless Flutter MapLibre GL upgrades as well.

@kuhnroyal
Copy link
Contributor

@stefanschaller Thanks! Can you please use https://pub.dev/packages/platform instead.

@stefanschaller
Copy link
Collaborator Author

stefanschaller commented Mar 31, 2025

@kuhnroyal I changed the dependency to platform, but I'm unsure about the goal since https://pub.dev/packages/platform is still importing dart:io; It's not working again in web with the latest commit.

@albertmoravec What would you recommend to do? We could also copy past some code to avoid dependencies, but I'm not a huge fan.
We could also use a wide range of versions like: universal_platform: ">=1.0.0 <2.0.0"

@kuhnroyal kuhnroyal force-pushed the 550-bug-unsupported-operation-platform_operatingsystem branch from 25cd21f to 68f981a Compare March 31, 2025 09:45
@kuhnroyal
Copy link
Contributor

Yea, sorry, I thought the platform package supports web...

Since the interface package already relies on Flutter, we can use kIsWeb (thanks @albertmoravec).
I added a test and CI test jobs.

@kuhnroyal kuhnroyal enabled auto-merge (squash) March 31, 2025 09:49
@kuhnroyal kuhnroyal merged commit 65086ab into main Mar 31, 2025
21 checks passed
@kuhnroyal kuhnroyal deleted the 550-bug-unsupported-operation-platform_operatingsystem branch March 31, 2025 09:54
@Live4win
Copy link

Live4win commented Mar 31, 2025

I could be wrong, but it seems that the 'Unsupported operation' error still persists even with the latest commits. Can anyone confirm?

@stefanschaller
Copy link
Collaborator Author

@kuhnroyal We are still using the io import, which is not working for web!

@stefanschaller stefanschaller restored the 550-bug-unsupported-operation-platform_operatingsystem branch March 31, 2025 14:25
@stefanschaller stefanschaller deleted the 550-bug-unsupported-operation-platform_operatingsystem branch March 31, 2025 14:25
@kuhnroyal
Copy link
Contributor

kuhnroyal commented Mar 31, 2025

No, this is compiled out for web as the kIsWeb is a compiler-constant.
The test is running successfully on Chrome.

@kuhnroyal
Copy link
Contributor

@kuhnroyal
Copy link
Contributor

Just the occurrence of the dart:io import does not prevent it from working on web, only if the dart:io code is called during runtime.

As you can see here, the example uses dart:io in its main.dart file:
https://github.com/maplibre/flutter-maplibre-gl/blob/main/maplibre_gl_example/lib/main.dart#L5

MichaelNeufeld pushed a commit to ocell/flutter-maplibre-gl that referenced this pull request Apr 23, 2025
MichaelNeufeld pushed a commit to ocell/flutter-maplibre-gl that referenced this pull request Sep 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Unsupported operation: Platform._operatingSystem

5 participants