Flutter Error: No named parameter with the name 'keyboardDismissBehavior' - flutter

The flutter project ran well on my android device before i ran flutter grade command. And then the project just cant run anyway without any code change. Here is the error message:
Launching lib/main.dart on RMX1971 in debug mode...
Running Gradle task 'assembleDebug'...
../../env/flutter/.pub-cache/hosted/pub.flutter-io.cn/pull_to_refresh-1.6.4/lib/src/smart_refresher.dart:434:9: Error: No named parameter with the name 'keyboardDismissBehavior'.
keyboardDismissBehavior:
^^^^^^^^^^^^^^^^^^^^^^^
../../env/flutter/packages/flutter/lib/src/widgets/scroll_view.dart:588:9: Context: Found this candidate, but the arguments don't match.
const CustomScrollView({
^^^^^^^^^^^^^^^^
FAILURE: Build failed with an exception.
Where:
Script '/Users/lgk/env/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 907
What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
Process 'command '/Users/lgk/env/flutter/bin/flutter'' 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 14s
Exception: Gradle task assembleDebug failed with exit code 1

This is actually a compatibility issue between pull_to_refresh plugin and the current version of Flutter during this time. There are some bugs related to this and most of the solutions were found on the thread:
https://github.com/peng8350/flutter_pulltorefresh/issues/427
https://github.com/peng8350/flutter_pulltorefresh/issues/424
To summarized the solution from this thread:
How to solve Error: No named parameter with the name 'keyboardDismissBehavior' ?
to solve Error: No named parameter
with the name 'keyboardDismissBehavior' This error is caused due to
pull_to_refresh plugin that you are using in your flutter app is not
compatible with the current version of flutter. The solution is just
downgraded your plugin version.
Error: No named parameter with the name 'keyboardDismissBehavior
to solve Error: No named parameter with
the name 'keyboardDismissBehavior' This error is caused due to
pull_to_refresh plugin that you are using in your flutter app is not
compatible with the current version of flutter. The solution is just
downgraded your plugin version.
Solution 1
This error is cause due to pull_to_refresh plugin that you are using
in your flutter app that is not compatible with the current version of
flutter. The solution is just to downgrade your plugin version. Just
Follow below step to solve this error.
Edit file pubspec.yaml
Change This Line pull_to_refresh ^1.6.4 or pull_to_refresh ^1.6.3
Replace with pull_to_refresh 1.6.3
run flutter clean
flutter run
Solution 2
pull_to_refresh plugin is not compatible with the current version of
flutter.

Related

pubpspect get failed when adding flutter_html lib in flutter

I have tried to build app 'flutter_html: ^2.1.5" but I unable to build and getting below error in log.
The current Flutter SDK version is 1.27.0-2.0.pre.1.
Because flutter_app depends on flutter_html >=2.1.0 which requires Flutter SDK version >=2.2.0, version solving failed.
pub get failed (1; Because flutter_app depends on flutter_html >=2.1.0 which requires Flutter SDK version >=2.2.0, version solving failed.)
can you suggest the way to clear this issue?
I have upgraded flutter version and migrated and having different issue.
FAILURE: Build failed with an exception.
* What went wrong:
A problem was found with the configuration of task ':app:checkDebugManifest' (type 'CheckManifest').
- In plugin 'com.android.build.gradle.api.AndroidBasePlugin' type 'com.android.build.gradle.internal.tasks.CheckManifest' property 'manifest' has #Input annotation used on property of type 'File'.
Reason: A property of type 'File' annotated with #Input cannot determine how to interpret the file.
Possible solutions:
1. Annotate with #InputFile for regular files.
2. Annotate with #InputDirectory for directories.
3. If you want to track the path, return File.absolutePath as a String and keep #Input.
Please refer to https://docs.gradle.org/7.2/userguide/validation_problems.html#incorrect_use_of_input_annotation for more details about this problem.
* 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 11s
Exception: Gradle task assembleDebug failed with exit code 1
You need to upgrade your flutter SDK. Write flutter upgrade in terminal.
Or use an older version of flutter_html.

gradle build failure Execution failed for task ':webview_flutter:compileDebugJavaWithJavac'

My flutter app doesn't even have webview_flutter plugin and it's showing error for that. Gradle build failure. First it told me to set minSDkVersion to 19. I did that but still error. I had the same app but different project running before with exact same code and plugins. I don't understand what's going on. Please help.
Launching lib\main.dart on Android SDK built for x86 in debug mode...
Running Gradle task 'assembleDebug'...
Note: C:\flutter\.pub-cache\hosted\pub.dartlang.org\thumbnails-
1.0.1\android\src\main\java\com\asapjay\thumbnails\ThumbnailsPlugin.java uses or overrides a
deprecated API.
Note: Recompile with -Xlint:deprecation for details.
C:\flutter\.pub-cache\hosted\pub.dartlang.org\webview_flutter-
2.0.6\android\src\main\java\io\flutter\plugins\webviewflutter\InputAwareWebView.java:31: error:
cannot find symbol
private ThreadedInputConnectionProxyAdapterView proxyAdapterView;
^
symbol: class ThreadedInputConnectionProxyAdapterView
location: class InputAwareWebView
C:\flutter\.pub-cache\hosted\pub.dartlang.org\webview_flutter-
2.0.6\android\src\main\java\io\flutter\plugins\webviewflutter\InputAwareWebView.java:112: error:
cannot find symbol
new ThreadedInputConnectionProxyAdapterView(
^
symbol: class ThreadedInputConnectionProxyAdapterView
location: class InputAwareWebView
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
2 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':webview_flutter:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* 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 44s
Exception: Gradle task assembleDebug failed with exit code 1
ThreadedInputConnectionProxyAdapterView has wrong extension .jav
You can just change it to .java by hand as a temporary fix.
or
I temporarily downgraded webview_flutter back to 2.0.4. (after downgrading webview_flutter if this solution not working then you need to check your pubsepc.lock file for webview_flutter, because some other dependencies may extend webview_flutter so this package will visible in pubsepc.lock file, then you just need downgrade webview_flutter from this file also)
Enjoy!
This happen because of the webview_flutter package version issue. I have downgrade the version and it worked. Go to the pubspec.yaml and downgrade the version to 2.0.14

How to fix this nullOk error when using the flutter_svg package?

I connected the package, added it to main.dart, I try to compile the application, but I get this error. Help! What should I do about it?
error
Launching lib\main.dart on XT1562 in debug mode...
Running Gradle task 'assembleDebug'...
/D:/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.18.1/lib/src/picture_provider.dart:50:59: Error: No named parameter with the name 'nullOk'.
context != null ? Localizations.localeOf(context, nullOk: true) : null,
^^^^^^
/D:/flutter/packages/flutter/lib/src/widgets/localizations.dart:413:17: Context: Found this candidate, but the arguments don't match.
static Locale localeOf(BuildContext context) {
^^^^^^^^
FAILURE: Build failed with an exception.
* Where:
Script 'D:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 991
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'D:\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 15s
Exception: Gradle task assembleDebug failed with exit code 1
Follow the steps below
add the following dependency
flutter_svg: ^0.20.0-nullsafety.3
run flutter clean command
run flutter pub get command
run flutter run command or run the project
Everyone is right: putting flutter_svg: ^0.20.0-nullsafety.3 or flutter_svg: ^0.19.3 (in case you can't migrate to null safety yet) is the solution.
I want to add a little thing: if you're using a package which depends on flutter_svg and you still get the error due to older versions usage, you can fix it in this way:
dependency_overrides:
flutter_svg: ^0.19.3
I lost plenty of time because the flags: ^3.2.2 package was using flutter_svg: ^0.19.1 and it led to the same error.
The problem is that the version of Flutter with null-safety enabled (currently on the beta channel as of writing), the nullOk parameter was removed Localizations.localeOf, but you're using a package (in this case, flutter_svg) that is still using nullOk.
If you're using the null-safe version of Flutter, you should use null-safe versions of other packages too, if available. Alternatively you can stick with the latest version of Flutter without null-safety (version 1.22.x) until all of your dependent packages have been migrated for null-safety.
I have faced the same problem . After I finally got the solution.
Here Simple:
At first you add Pre-Release the following dependency:
flutter_svg: ^0.20.0-nullsafety.3
Then run flutter pub get command
Now you can run your project . See that there is no error .
On line 57 of the locally cached file /lib/src/picture_provider.dart (see the full path from the error message)replace
Localizations.localeOf(context, nullOk: true), with Localizations.maybeLocaleOf(context)
This is quick and dirty solution, but should hold until the package is fixed.
Note that if you want to fix this error for yourself or for a package that you are using, you can fix it the following way
In order to modify your code to use the new form of the APIs, convert all instances of calls that include nullOk = true as a parameter to use the maybe form of the API instead.
MediaQueryData? data = MediaQuery.of(context, nullOk: true);
becomes
MediaQueryData? data = MediaQuery.maybeOf(context);
More about how to migrate towards null-safety in the official documentation
Tried everything, in vain.
Finally, the updating a dependency worked for me.
This is what I updated in my pubspec.yaml file:
Removed
flutter_svg: ^0.18.0
and added
flutter_svg: ^0.20.0-nullsafety.3
Then, ran
flutter pub get
simply go into the file in .pub-cache and correct the argument from localeOf(context, nullOk: true) to localeOf(context)

Target kernel_snapshot failed: Exception: Errors during snapshot creation: null build failed

I have updated to the latest flutter update. When I want to start the project, it returns an error. The project depends on several repositories and I don't know if that is why. I have tried multiple solutions but they do not solve the error. Hope someone can help me. thanks.
Compiler message:
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/mvvm-0.1.7/lib/view_context_helpers/logical.dart:151:25: Error: The function expression type 'Widget Function(BuildContext, Null, Widget) Function(TValue)' isn't of expected type 'Widget Function(BuildContext, TValue, Widget) Function(TValue)'.
- 'Widget' is from 'package:flutter/src/widgets/framework.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/framework.dart').
- 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/framework.dart').
Change the type of the function expression or the context in which it is used.
selector: (TValue value) =>
^
Target kernel_snapshot failed: Exception: Errors during snapshot creation: null
build failed.
FAILURE: Build failed with an exception.
* Where:
Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 780
* 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
BU�LD FAILED in 31s
Finished with error: Gradle task assembleDebug failed with exit code 1
i found this issue issue TL:DR here is a summary
It looks like your local engine build flutter/engine and framework + tool flutter/flutter are out of sync: You're using an engine from when after SemanticsFlag.isLink was added, but a framework/tool from before it rolled into the framework.
You need to ensure that you're using compatible engines and frameworks. In this case, you need to either update flutter/flutter to a newer version or roll back flutter/engine to an older version.42356
Solution 1
1.Ensure compatible engines and frameworks.
2.Update flutter or install flutter to a newer version,
still issue persists, Roll back flutter or engine to an older version.
Best solution to fix by time saving but not preferable, please follow
Solution 2
1. Download latest version flutter sdk and setup.
2. Fix it by creating a new project and copying the code from the old one.
For more details refer the below link
http://codekhichdi.com/flutter/target-kernel_snapshot-failed-exception-errors-during-snapshot-creation-null
If upgrade/downgrade as mentioned above still doesn't fix the issue, perhaps the flutter channel is in master or else. Change the channel to 'stable' with:
flutter channel stable
After changing the channel, upgrade it:
flutter upgrade
reopen the editor/ide to make sure it's using the new engine, and then run your project.
This method worked for me.

Flutter: build error when adding "image_cropper" and "contacts_service" packages

I can successfully build and run a fresh new flutter project. But when I add both image_cropper: ^1.0.0 and contacts_service: ^0.2.4 packages to pubspec.yaml and run flutter packages get, I cannot build the project anymore, and get this build error:
D8: Program type already present: android.support.v4.app.INotificationSideChannel
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\2.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\3.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\4.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\5.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\6.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\7.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\8.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\9.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\10.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\11.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\12.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\13.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\14.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\15.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\16.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\17.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\18.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\19.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\20.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\21.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\22.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\23.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\24.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\25.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\26.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\27.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\28.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\29.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\30.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\31.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\32.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\33.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\34.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\35.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\36.jar
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Program type already present: android.support.v4.app.INotificationSideChannel
* 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 1m 19s
*******************************************************************************************
The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
See https:///CP92wY for more information on the problem and how to fix it.
*******************************************************************************************
Finished with error: Gradle task assembleDebug failed with exit code 1
I do not understand this error very well, but it seems that there is a naming conflict between these two packages (because of duplicate_classes in the error text). Is there any workaround for this?
Note that this error does not happen with any other pair of packages for me.
In build.gradle defaultConfig add multiDexEnabled true
This was an Android X compatibility issue. I could get it fixed by following the steps mentioned here, but in summary:
First make sure that compileSdkVersion is at least 28 in app/build.gradle. This property controls the version of the Android SDK that Gradle uses to build your APK. It doesn’t affect the minimum SDK version that your app can run on.
Right click on android directory of flutter project and open it using this menu: Flutter > Open android module in android studio
In the newly opened project, from menus select Refactor > Migrate to AdnroidX
Close the project and open your flutter project again.