I’m showing an AlertDialog on my App, but when I click on no/cancel then AlertDialog doesn’t dismiss, it keep popping the route where I came from. I’ve used Navigator.of(context).pop(); and Navigator.pop(context, false); but both are not working.
Solution
To Dismiss an AlertDialog Navigator.of(context).pop(); works but in my case below code worked.
I have implemented firebase phone Auth in my flutter app but whenever i fill phone no. and click on send otp then it opens a RECAPTCHA verification url in browser by default. I don’t want to show it.
See the below screenshot of popup.
Solution
Follow the below Steps :-
Step 1 :- Go to Google Cloud Console, enable the Android Device Check API for your project ( Select the same project which you have created in firebase for flutter App. ). The default Firebase API Key will be used, and needs to be allowed to access the DeviceCheck API.
Step 2 :- If you haven’t added SHA-256 fingerprint in firebase then add it too.
For more information, you can also check Google SafetyNet API for checking Google Play Services installation in device at the time of Phone Authentication.
After upgrading firebase_auth to latest version (i.e., ^1.2.0), it says update intl to ^0.17.0. When i updated intl, I’m getting errors when I try to run flutter pub get.
C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-9.1.4\android\src\main\java\io\flutter\plugins\firebase\messaging\FlutterFirebaseMessagingPlugin.java:20: error: cannot find symbol
import com.google.firebase.iid.FirebaseInstanceId;
^
symbol: class FirebaseInstanceId
location: package com.google.firebase.iid
C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-9.1.4\android\src\main\java\io\flutter\plugins\firebase\messaging\FlutterFirebaseMessagingPlugin.java:21: error: cannot find symbol
import com.google.firebase.iid.Metadata;
^
symbol: class Metadata
location: package com.google.firebase.iid
C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-9.1.4\android\src\main\java\io\flutter\plugins\firebase\messaging\FlutterFirebaseMessagingPlugin.java:152: error: cannot find symbol
: Metadata.getDefaultSenderId(FirebaseApp.getInstance());
^
symbol: variable Metadata
location: class FlutterFirebaseMessagingPlugin
C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-9.1.4\android\src\main\java\io\flutter\plugins\firebase\messaging\FlutterFirebaseMessagingPlugin.java:153: error: cannot find symbol
FirebaseInstanceId.getInstance().deleteToken(senderId, "*");
^
symbol: variable FirebaseInstanceId
location: class FlutterFirebaseMessagingPlugin
C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-9.1.4\android\src\main\java\io\flutter\plugins\firebase\messaging\FlutterFirebaseMessagingPlugin.java:165: error: cannot find symbol
: Metadata.getDefaultSenderId(FirebaseApp.getInstance());
^
symbol: variable Metadata
location: class FlutterFirebaseMessagingPlugin
C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-9.1.4\android\src\main\java\io\flutter\plugins\firebase\messaging\FlutterFirebaseMessagingPlugin.java:166: error: cannot find symbol
String token = FirebaseInstanceId.getInstance().getToken(senderId, "*");
^
symbol: variable FirebaseInstanceId
location: class FlutterFirebaseMessagingPlugin
Solution
Update firebase_messaging to latest one (Currently i.e., firebase_messaging: ^10.0.0), and call flutter pub get.
The android studio while running throws this error and stop the build
A:\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
A:\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.
Solution
ThreadedInputConnectionProxyAdapterView has wrong extension .jav just change it to .java until the flutter team release the fix.
Its Located to :- C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\webview_flutter-2.0.6\android\src\main\java\io\flutter\plugins\webviewflutter
I’m using flutter_recaptcha_v2: ^0.1.0. Now, I am trying to run it using flutter run, however, it will not start because of the following error:
Error: Cannot run with sound null safety, because the following dependencies
don't support null safety:
- package:flutter_recaptcha_v2
- package:webview_flutter
- package:http
- package:http_parser
For solutions, see https://dart.dev/go/unsound-null-safety
FAILURE: Build failed with an exception.
* Where:
Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1035
* 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 21s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
Solution
If you want run your project with --no-sound-null-safety so now you add this line your main.dart file in top(first line) with comment..
I’m Calling An API and getting response in Variable Data ($data). When data is coming then there is no Error but when I’m getting null as response then getting this error Unhandled Exception: NoSuchMethodError: The getter ‘isEmpty’ was called on null.
When I am using the below code then it is throwing me an error:
Solution
That is because $data returns null, So I’ve Used
if(data?.isEmpty ?? true)
? prevents an error if the previous part of the expression results in null and ?? true results in true if the previous part of the expression is null and therefore treats == null and isEmpty the same for the if(...) check.
I’ve connected my flutter app to firebase by adding SHA1 key ( How to Get SHA-1 key in Android Studio for Firebase. ) and package name in firebase console, and also downloaded and provided google-service.json in my flutter app at android/app. But when i run app its Showing an error that i’ve not provided google-service.json file in my app. The Error Says –
E/flutter (15568): [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: [core/not-initialized] Firebase has not been correctly initialized. Have you added the "google-services.json" file to the project?
E/flutter (15568):
Solution
After hours of struggle, I am able to figure out the solution.
1. First, add the ‘google-services.json‘ plugin as a dependency inside of the android/build.gradle file:
2. Lastly, execute the plugin by adding the following underneath the line apply plugin: add after ‘com.android.application’, within the /android/app/build.gradle file: