dart-lang / http

A composable API for making HTTP requests in Dart.
https://pub.dev/packages/http
BSD 3-Clause "New" or "Revised" License
1.02k stars 354 forks source link

http package src error message while debugging project #678

Closed himmat12 closed 2 years ago

himmat12 commented 2 years ago

debug log

Launching lib\main.dart on SM G610F in debug mode...
lib\main.dart:1
Warning: Mapping new ns [http://schemas.android.com/repository/android/common/02]() to old ns [http://schemas.android.com/repository/android/common/01]()
Warning: Mapping new ns [http://schemas.android.com/repository/android/generic/02]() to old ns [http://schemas.android.com/repository/android/generic/01]()
Warning: Mapping new ns [http://schemas.android.com/sdk/android/repo/addon2/02]() to old ns [http://schemas.android.com/sdk/android/repo/addon2/01]()
Warning: Mapping new ns [http://schemas.android.com/sdk/android/repo/repository2/02]() to old ns [http://schemas.android.com/sdk/android/repo/repository2/01]()
Warning: Mapping new ns [http://schemas.android.com/sdk/android/repo/sys-img2/02]() to old ns [http://schemas.android.com/sdk/android/repo/sys-img2/01]()
: Error: A method declaration needs an explicit list of parameters.
package:http/src/response.dart:28
Try adding a parameter list to the method declaration.
  String getbody => _encodingForHeaders(headers).decode(bodyBytes);
         ^^^^^^^
: Error: The getter 'body' isn't defined for the class 'Response'.
../…/src/base_client.dart:53
- 'Response' is from 'package:http/src/response.dart' ('.[./../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/http-0.13.4/lib/src/response.dart]()').
package:http/src/response.dart:1
Try correcting the name to the name of an existing getter, or defining a getter or field named 'body'.
    return response.body;

                    ^^^^
2

FAILURE: Build failed with an exception.

* Where:
Script '[C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle]()' line: 1102

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command '[C:\src\flutter\bin\flutter.bat]()'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at [https://help.gradle.org]()

BUILD FAILED in 41s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

flutter run -v

flutter run -v log

flutter doctor

PS C:\Users\Dell\Desktop\weather_app> flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.10.3, on Microsoft Windows [Version 10.0.19044.1586], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[√] Chrome - develop for the web
[!] Visual Studio - develop for Windows (Visual Studio Community 2022 17.1.1)   
    X Visual Studio is missing necessary components. Please re-run the Visual Studio installer for the "Desktop development with C++" workload, and include these components:
        MSVC v142 - VS 2019 C++ x64/x86 build tools
         - If there are multiple build tool versions available, install the latest
        C++ CMake tools for Windows
        Windows 10 SDK
[√] Android Studio (version 2020.3)
[√] VS Code (version 1.65.2)        
[√] Connected device (4 available)  
[√] HTTP Host Availability

! Doctor found issues in 1 category.
2shrestha22 commented 2 years ago

Have you tried with different version of this package and flutter? Try changing package version and flutter version then clean build.

himmat12 commented 2 years ago

@2shrestha22 not yet but will try it asap i think this current version of http package was working fine fews days back like 4 5 days but now the same version throws error message after breaking the debug

natebosch commented 2 years ago

It looks like you made a local edit in your pub cache. It might work to repair all packages (note this can be very slow)

https://dart.dev/tools/pub/cmd/pub-cache#reinstalling-all-packages-in-the-system-cache

In the future, I'd avoid making edits in package downloaded by pub.

himmat12 commented 2 years ago

@natebosch yea yesterday i figured it out and fixed the issue by deleting the whole cache anyway thank you for your help , appreciate it😊