dart-lang / webdev

A CLI for Dart web development.
https://pub.dev/packages/webdev
212 stars 75 forks source link

error when get json from api asp.core (flutter_web) #673

Closed mahmoudsalah37 closed 5 years ago

mahmoudsalah37 commented 5 years ago

//http://api.mp3quran.net/api/surah?surah=1&language=en (this work with flutter & flutter_web) //http://qualityproject-001-site1.ctempurl.com/api/v1/Policy (but this not work with flutter_web and work with flutter)

import 'package:http/http.dart';
fetchPost() async {
  Response response =
      await get('http://qualityproject-001-site1.ctempurl.com/api/v1/Policy');
  print(response.body);
}

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

This looks like it isn't related to package:http but is instead related to dwds..

jakemac53 commented 5 years ago

Sorry about the delay here, this one slipped through the cracks a bit.

@alan-knight do you think https://github.com/dart-lang/webdev/pull/699 will fix this also?

alan-knight commented 5 years ago

Yes, this looks like the same issue as #690 and should be fixed by #699

jakemac53 commented 5 years ago

Closing as that pr was submitted