basicLocaleListResolution’ is imported from both error - flutter

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=[];

Related

flutter test: Run | Debug | Profile button runs Gradle task and does not run the unit test

I am writing unit test for my flutter application but could not run the unit test with the Run | Debug | Profile button above the main() function of the test file.
I have the test file as follow:
void main() {
late HttpServiceBase httpServicBase;
setUpAll(() {
httpServicBase = HttpServiceBase();
});
group("get", () {
test("given empty url, should throw exception", () {
// some test code
});
});
}
I can see the Run | Debug | Profile button above the main function.
However, when I click the Debug button, I get the following error
Build file 'D:\FlutterApp\android\app\build.gradle' line: 90
* What went wrong:
A problem occurred evaluating project ':app'.
> Parameter specified as non-null is null: method com.android.build.gradle.internal.dsl.BaseFlavor.resValue, parameter value
* 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 4s
Exception: Gradle task assembleDebug failed with exit code 1
However, when I run flutter test .\tests\unit_tests\libs\services\http_service_test.dart, the test runs as expected.
I don't have specific setup so I don't know what could be wrong.
Thank you
Rename the folder from tests to test solves the problem.

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

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.

VS code is importing renamed packages

I renamed Warehouse_edit_repository.dart to warehouse_edit_repository.dart
But when I import the file and try to run the program I get this error
- 'WarehouseEditRepository/*1*/' is from 'package:bhoomi/data/repository/warehouse_edit_repository.dart' ('lib/data/repository/warehouse_edit_repository.dart').
- 'WarehouseEditRepository/*2*/' is from 'package:bhoomi/data/repository/Warehouse_edit_repository.dart' ('lib/data/repository/Warehouse_edit_repository.dart').
EditWarehouseBloc(editWarehouseRepository: WarehouseEditRepository())
^
lib/screens/project_screens/purch_mgmt_screens/masters/warehouse_screen/warehouse_edit_screen.dart:178:14: Error: Type argument 'EditWarehouseBloc' doesn't conform to the bound 'BlocBase<S>' of the type variable 'B' on 'BlocConsumer'.
- 'EditWarehouseBloc' is from 'package:bhoomi/bloc/warehouse_view_bloc/warehouse_view_bloc.dart' ('lib/bloc/warehouse_view_bloc/warehouse_view_bloc.dart').
- 'BlocBase' is from 'package:bloc/src/bloc.dart' ('/C:/flutter/.pub-cache/hosted/pub.dartlang.org/bloc-7.2.1/lib/src/bloc.dart').
Try changing type arguments so that they conform to the bounds.
child: BlocConsumer<EditWarehouseBloc, EditWarehouseState>(
^
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_bloc-7.3.3/lib/src/bloc_consumer.dart:61:20: Context: This is the type variable whose bound isn't conformed to.
class BlocConsumer<B extends BlocBase<S>, S> extends StatefulWidget {
^
lib/screens/project_screens/purch_mgmt_screens/masters/warehouse_screen/warehouse_edit_screen.dart:702:58: Error: The argument type 'AddWarehouseModel/*1*/' can't be assigned to the parameter type 'AddWarehouseModel/*2*/'.
- 'AddWarehouseModel/*1*/' is from 'package:bhoomi/data/model/add_warehouse_repository.dart' ('lib/data/model/add_warehouse_repository.dart').
- 'AddWarehouseModel/*2*/' is from 'package:bhoomi/data/model/add_Warehouse_repository.dart' ('lib/data/model/add_Warehouse_repository.dart').
model: model));
^
FAILURE: Build failed with an exception.
* Where:
Script 'C:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1102
* 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.
I deleted vs code, tried writing the code again removing imports and importing again used as in imports but doesn't work. Any solutions?
It's possible that you have import statements that are still using the old casing. Try searching for Warehouse_edit_repository and add_Warehouse_repository across your workspace with the Case Sensitivity setting enabled in VS Code, and correct any that are using the wrong casing.

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

Dart uuid can't be extended

I updated dependencies by dart pub upgrade, but here i thought due to some cache already there causing this error. i have tried dart clean cache but problem is still there. kindly take this issue underconsideration problem statement is mentioned below. It seems like my uuid class can't extend umodifiableuint8listview but class is not even present in the code
**../../flutter/.pub-cache/hosted/pub.dartlang.org/uuid_enhanced-3.0.2/lib/uuid.dart:9:7: Error: 'UnmodifiableUint8ListView' is restricted and can't be extended or implemented.
class Uuid extends UnmodifiableUint8ListView {
^**
2
FAILURE: Build failed with an exception.
* Where:
Script 'C:\Users\hp\Documents\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1005
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\Users\hp\Documents\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 54s
Exception: Gradle task assembleDebug failed with exit code 1