dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.27k stars 1.58k forks source link

get json from api server asp.core (flutter web) #38444

Closed mahmoudsalah37 closed 5 years ago

mahmoudsalah37 commented 5 years ago

when i try another url worked and get json like: http://api.mp3quran.net/api/surah?surah=1&language=en

put this link not work

link:http://qualityproject-001-site1.ctempurl.com/api/v1/Policy

note: this api built by asp.core

putJson() async {
   print(await HttpRequest.getString('http://qualityproject-001-site1.ctempurl.com/api/v1/Policy',
   withCredentials: false));
}

Flutter crash report; please file at https://github.com/flutter/flutter/issues.

command

flutter run --machine --target lib\main.dart -d chrome --track-widget-creation --start-paused

exception

NoSuchMethodError: NoSuchMethodError: The method 'toJson' was called on null. Receiver: null Tried calling: toJson()

#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
#1      SourceLocation.toJson (package:vm_service/vm_service.dart:5024:24)
#2      Frame.toJson (package:vm_service/vm_service.dart:3296:47)
#3      Event.toJson (package:vm_service/vm_service.dart:3022:47)
#4      VmServerConnection._delegateRequest.<anonymous closure> (package:vm_service/vm_service.dart:1141:28)
#5      _rootRunUnary (dart:async/zone.dart:1132:38)
#6      _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#7      _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7)
#8      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#9      _DelayedData.perform (dart:async/stream_impl.dart:591:14)
#10     _StreamImplEvents.handleNext (dart:async/stream_impl.dart:707:11)
#11     _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:667:7)
#12     _rootRun (dart:async/zone.dart:1120:38)
#13     _CustomZone.run (dart:async/zone.dart:1021:19)
#14     _CustomZone.runGuarded (dart:async/zone.dart:923:7)
#15     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:963:23)
#16     _rootRun (dart:async/zone.dart:1124:13)
#17     _CustomZone.run (dart:async/zone.dart:1021:19)
#18     _CustomZone.runGuarded (dart:async/zone.dart:923:7)
#19     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:963:23)
#20     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#21     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#22     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:116:13)
#23     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:173:5)

flutter doctor

[✓] Flutter (Channel unknown, v1.10.2-pre.40, on Microsoft Windows [Version 10.0.17134.1006], locale en-US)
    • Flutter version 1.10.2-pre.40 at C:\flutter\flutter
    • Framework revision b4ab5cfe79 (29 hours ago), 2019-09-16 20:34:25 -0700
    • Engine revision 7ea9884ab0
    • Dart version 2.5.0 (build 2.5.0-dev.4.0 be66176534)

[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at C:\flutter\sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • ANDROID_HOME = C:\flutter\sdk
    • Java binary at: C:\flutter\android-studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b01)
    ✗ Android license status unknown.
      Try re-installing or updating your Android SDK Manager.
      See https://developer.android.com/studio/#downloads or visit https://flutter.dev/setup/#android-setup for detailed instructions.

[✓] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[✓] Android Studio (version 3.3)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 34.0.1
    • Dart plugin version 182.5215
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)

[✓] Android Studio (version 3.5)
    • Android Studio at C:\flutter\android-studio
    • Flutter plugin version 34.0.4
    • Dart plugin version 191.6183.88
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b01)

[✓] VS Code (version 1.38.1)
    • VS Code at C:\Users\Mahmoud salah eldin\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.4.1

[✓] Connected device (2 available)
    • Chrome • chrome • web-javascript • Google Chrome 76.0.3809.132
    • Server • web    • web-javascript • Flutter Tools

! Doctor found issues in 1 category.
srawlins commented 5 years ago

Indeed, the SourceLocation class has no method, toJson. See the docs:

https://pub.dev/documentation/vm_service/latest/vm_service/SourceLocation-class.html