Error: 'kethrow' isn't a type. kethrow _ClientSocketException(error, request.url); - flutter

Building flutter application is giving an error.When i try to build my application the error is occured.
The error is:
**/C:/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.13.5/lib/src/io_client.dart:88:7: Error: 'kethrow' isn't a type.
kethrow _ClientSocketException(error, request.url);
^^^^^^^
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.13.5/lib/src/io_client.dart:88:15: Error: Expected ';' after this.
kethrow _ClientSocketException(error, request.url);
^^^^^^^^^^^^^^^^^^^^^^
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.13.5/lib/src/io_client.dart:88:43: Error: Expected ')' before this.
kethrow _ClientSocketException(error, request.url);
^
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.13.5/lib/src/io_client.dart:48:30: Error: A non-null value must be returned since the return type 'IOStreamedResponse' doesn't allow null.
- 'IOStreamedResponse' is from 'package:http/src/io_streamed_response.dart' ('/C:/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.13.5/lib/src/io_streamed_response.dart').
package:http/src/io_streamed_response.dart:1
Future<IOStreamedResponse> send(BaseRequest request) async {
^
3
FAILURE: Build failed with an exception.
* Where:
Script 'C:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1156
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\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 5m 45s
Exception: Gradle task assembleDebug failed with exit code 1**
How to fix this error.Thanks in advance.

I ran into this error a few days ago. It is strangely from the dart file. Mine was 'heethrow'. I corrected it by following the link to the file: /C:/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.13.5/lib/src/io_client.dart.
How to go about it:
Open location /C:/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.13.5/lib/src/ in Visual Studio Code
inside the src folder, open io_client.dart
(make sure you're in the io_client.dart inside the src folder)
Once you're in io_client.dart, locate the place with the error: in your case, it says 88:7 that is, line 88 column 7. Scroll to line number 88 and change 'kethrow' to 'throw'
the errors in the other places as marked in the image below should be corrected and your io_client.dart should be error free.
Note: other files outside io_client.dart might mark red indicating errors but never mind. Just save your changes in the io_client.dart file and close the file. Once closed
Open your project again and run flutter clean in the terminal.
next run flutter pub get
next run flutter pub upgrade
run your app again, everything should work fine.
But I'd advise you don't always go into those files to edit anything. I did that because I've tried every possible solution and needed to deliver my work. I even installed Visual Studio for Windows as suggested by flutter doctor, but that was not the solution.

Related

Accidently replaced '.r' through whole app with '' in flutter project

I had lots of reference of '.r' through my flutter app and I replaced all '.r' references with '' empty string and I came to to know that dart files also have been modified and now I get these errors in my debug console. I tried to fix these but seems like re-adding '.r' isn't fixing these problems.
Debug Console:
Launching lib\main.dart on sdk gphone x86 in debug mode...
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-2.1.3/lib/src/path_provider_windows_real.dart:117:66: Error: Member not found: 'roamingAppData'.
final String? appDataRoot = await
getPath(WindowsKnownFolder.roamingAppData);
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-2.1.3/lib/src/path_provider_windows_real.dart:146:60: Error: The method 'rsetGUID' isn't defined for the class 'GUID'.
'GUID' is from 'package:win32/src/guid.dart' ('/C:/flutter/.pub-cache/hosted/pub.dartlang.org/win32-3.0.1/lib/src/guid.dart').
Try correcting the name to the name of an existing method, or defining a method named 'rsetGUID'.
final Pointer knownFolderID =
calloc().ref.rsetGUID(folderID);
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-2.1.3/lib/src/path_provider_windows_real.dart:235:5: Error: Expected an identifier, but got '.'.
Try inserting an identifier before '.'.
.replaceAll(RegExp(r'[<>:"/\\|?*]'), '_');
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-2.1.3/lib/src/path_provider_windows_real.dart:237:9: Error: Expected an identifier, but got '.'.
Try inserting an identifier before '.'.
.trimRight();
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-2.1.3/lib/src/path_provider_windows_real.dart:239:5: Error: Expected an identifier, but got '.'.
Try inserting an identifier before '.'.
.replaceAll(RegExp(r'[<>:"/\|?*]'), '_');
FAILURE: Build failed with an exception.
Where:
Script 'C:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1159
What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
Process 'command 'C:\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 10s Exception: Gradle task assembleDebug failed with exit code 1 Exited (sigterm)

How to solve "Type 'GenerateAppTitle' not found"?

I would like to start a Flutter counter app. So I prepared all and started the flutter counter project.
Then I got this error:
Launching lib\main.dart on Android SDK built for x86 in debug mode...
Running Gradle task 'assembleDebug'...
../../../../../flutter/packages/flutter/lib/src/material/app.dart:365:9: Error: Type 'GenerateAppTitle' not found.
final GenerateAppTitle? onGenerateTitle;
^^^^^^^^^^^^^^^^
../../../../../flutter/packages/flutter/lib/src/cupertino/app.dart:292:9: Error: Type 'GenerateAppTitle' not found.
final GenerateAppTitle? onGenerateTitle;
^^^^^^^^^^^^^^^^
../../../../../flutter/packages/flutter/lib/src/material/app.dart:365:9: Error: 'GenerateAppTitle' isn't a type.
final GenerateAppTitle? onGenerateTitle;
^^^^^^^^^^^^^^^^
../../../../../flutter/packages/flutter/lib/src/cupertino/app.dart:292:9: Error: 'GenerateAppTitle' isn't a type.
final GenerateAppTitle? onGenerateTitle;
^^^^^^^^^^^^^^^^
FAILURE: Build failed with an exception.
* Where:
Script 'C:\Users\{mywindowsname}\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1156
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\Users\{mywindowsname}\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 20s
Exception: Gradle task assembleDebug failed with exit code 1
I already tried everything within the following error question on "Execution failed for task ':app:compileFlutterBuildDebug'." error message until Jakub S. answer to remove .gradle folder.
how to solve Execution failed for task ':app:compileFlutterBuildDebug'
Currently I think the problem is with the '"GenerateAppTitle" not found' message.
I tried the counter app on VS Code and Android Studio.
Nothing worked. What could the solution be?

Flutter - build failed in

run code after one year then face this issue
when flutter run command then command response error
how can remove these error
also run command flutter create -t app
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_math_fork-0.3.3+1/lib/src/widgets/selectable.dart:407:7: Error: The non-abstract class 'InternalSelectableMathState' is missing implementations for these members:
TextSelectionDelegate.copySelection
TextSelectionDelegate.cutSelection
TextSelectionDelegate.pasteText
TextSelectionDelegate.selectAll
Try to either
provide an implementation,
inherit an implementation from a superclass or mixin,
mark the class as abstract, or
provide a 'noSuchMethod' implementation.
class InternalSelectableMathState extends State
^^^^^^^^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/services/text_input.dart:1034:8: Context: 'TextSelectionDelegate.copySelection' is defined here.
void copySelection(SelectionChangedCause cause);
^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/services/text_input.dart:1014:8: Context: 'TextSelectionDelegate.cutSelection' is defined here.
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 25s
Running Gradle task 'assembleDebug'... 26.1s
Exception: Gradle task assembleDebug failed with exit code 1
Well, I hate bringing you bad news, but Flutter received a LOT of updates. You might want to either
Use an older version of Flutter (see: THIS LINK)
Refactor your code to adhere to the changes

basicLocaleListResolution’ is imported from both error

I've been getting an error like this for a few days now and couldn't find a solution. I did flutter clean and flutter run but no change
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/device_preview-0.5.5/lib/src/state/store.dart:74:31: Error: ‘basicLocaleListResolution’ is imported from both ‘package:flutter/src/widgets/app.dart’ and ‘package:device_preview/src/locales/locales.dart’.
final defaultLocale = basicLocaleListResolution(
^^^^^^^^^^^^^^^^^^^^^^^^^
2
FAILURE: Build failed with an exception.
Where:
Script ‘C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle’ line: 1005
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.
You have two class with same name. if you want use both of them. after one of imports write as [name]. for example
import 'package:flutter/adir/a.dart';
import 'package:flutter/bdir/a.dart' as newA;
and when want use it. first write custom name then write class name:
final List<newA.a> ex=[];

Why do I get "FAILURE: Build failed with an exception."?

When I try to start my app I get an error. I think I get the error because I tried to add a video in my app, because before I did this everything worked without an error.
This is the error:
Launching lib\main.dart on SM J530F in debug mode...
Running Gradle task 'assembleDebug'...
Target debug_android_application failed: FileSystemException: Cannot copy file to 'C:\Users\Simon\Desktop\App Entwickeln\Projekte\trainings_app\build\app\intermediates\flutter\debug\flutter_assets\assets/coffee.mp4', path = 'C:\Users\Simon\Desktop\App Entwickeln\Projekte\trainings_app\assets\coffee.mp4' (OS Error: Zugriff verweigert
, errno = 5)
build failed.
FAILURE: Build failed with an exception.
* Where:
Script 'C:\Users\Simon\Desktop\App Entwickeln\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 882
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\Users\Simon\Desktop\App Entwickeln\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 26s
Exception: Gradle task assembleDebug failed with exit code 1
Try flutter clean then build again
That looks like a file permissions related issue. Do you get error when you try below code in command line? If you have you need to check permission of the path you gave.
copy "C:\Users\Simon\Desktop\App Entwickeln\Projekte\trainings_app\assets\coffee.mp4" "C:\Users\Simon\Desktop\App Entwickeln\Projekte\trainings_app\build\app\intermediates\flutter\debug\flutter_assets\assets/coffee.mp4"