Skip to content
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

Automatic Sorting of Content in flutter web dio.get() Response #2007

Closed
sherrylin728 opened this issue Oct 23, 2023 · 2 comments
Closed

Automatic Sorting of Content in flutter web dio.get() Response #2007

sherrylin728 opened this issue Oct 23, 2023 · 2 comments

Comments

@sherrylin728
Copy link

sherrylin728 commented Oct 23, 2023

Package

dio

Version

5.3.3

Operating-System

Web

Output of flutter doctor -v

[✓] Flutter (Channel stable, 3.10.6, on macOS 13.5.2 22G91 darwin-arm64, locale zh-Hant-TW)
    • Flutter version 3.10.6 on channel stable at /Users/linyunxuan/development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision f468f3366c (3 months ago), 2023-07-12 15:19:05 -0700
    • Engine revision cdbeda788a
    • Dart version 3.0.6
    • DevTools version 2.23.1

[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/linyunxuan/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Users/linyunxuan/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/223.8836.35.2231.10406996/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.

[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15A507
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.3)
    • Android Studio at /Users/linyunxuan/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/223.8836.35.2231.10406996/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)

[✓] IntelliJ IDEA Community Edition (version 2022.2.3)
    • IntelliJ at /Users/linyunxuan/Library/Application Support/JetBrains/Toolbox/apps/IDEA-C/ch-0/222.4345.14/IntelliJ IDEA CE.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] IntelliJ IDEA Community Edition (version 2023.1.2)
    • IntelliJ at /Users/linyunxuan/Library/Application Support/JetBrains/Toolbox/apps/IDEA-C/ch-0/231.9011.34/IntelliJ IDEA CE.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.81.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (3 available)
    • Android SDK built for arm64 (mobile) • emulator-5554 • android-arm64  • Android 10 (API 29) (emulator)
    • macOS (desktop)                      • macos         • darwin-arm64   • macOS 13.5.2 22G91 darwin-arm64
    • Chrome (web)                         • chrome        • web-javascript • Google Chrome 118.0.5993.88

[✓] Network resources
    • All expected network resources are available.

Dart Version

3.0.6

Steps to Reproduce

When calling the API and requesting data in descending order by number, it returns in ascending order instead. However, when I use a mobile device to call this API, it works correctly.

Expected Result

截圖 2023-10-23 下午3 14 43

Actual Result

截圖 2023-10-23 下午2 52 15

@sherrylin728 sherrylin728 added h: need triage This issue needs to be categorized s: bug Something isn't working labels Oct 23, 2023
@AlexV525
Copy link
Member

Could you provide a reproducible example for this?

@AlexV525 AlexV525 added the h: need more info Further information is requested label Oct 23, 2023
@sherrylin728
Copy link
Author

I've identified the root cause and fixed it.
In JavaScript (which Flutter web relies on for web applications), the order of keys in an object is not guaranteed to be preserved. This means that when you decode a JSON string and convert it to a Dart map, the keys may appear sorted even though the original JSON data was unordered.
This issue will be closed. Thank you.

@AlexV525 AlexV525 added i: out of support and removed h: need more info Further information is requested h: need triage This issue needs to be categorized s: bug Something isn't working labels Oct 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants