I'm trying to run tests to ensure that my flutter database works as intended however when ran I get the following error:
package:flutter/src/services/platform_channel.dart 319:7 MethodChannel.invokeMethod
MissingPluginException(No implementation found for method getApplicationDocumentsDirectory on channel plugins.flutter.io/path_provider)
The app itself can access getApplicationDocumentsDirectory but not the test iself.
Here is my test suit:
import 'package:ema/DatabaseHelper.dart';
import 'package:ema/Readings.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:path/path.dart';
import 'package:ema/main.dart';
void main() {
test("Tests to ensure that the database is working as intended ", () async {
runApp(MyApp());
//first checks to see if the database is generated and is empty
List<Reading> dbResults = await DatabaseHelper.db.getReadings();
expect(0, dbResults.length);
});
}
dear, I think you should:
- stop the execution of your application
- re-run it
hot reload works only on dart code (lib)
Related
I try to get a local debug token according to the instructions, but I don't see any in the console. I implemented this code as given. Is it maybe because the release and debug app-check don't work at the same time?
Guide: https://firebase.google.com/docs/app-check/android/debug-provider?hl=en#java_1, Point 3 doesn't work for me
MainActivity.java
import com.google.firebase.FirebaseApp;
import com.google.firebase.appcheck.FirebaseAppCheck;
import com.google.firebase.appcheck.playintegrity.PlayIntegrityAppCheckProviderFactory;
import com.google.firebase.appcheck.debug.DebugAppCheckProviderFactory;
FirebaseApp.initializeApp(/*context=*/ this);
FirebaseAppCheck firebaseAppCheck = FirebaseAppCheck.getInstance();
firebaseAppCheck.installAppCheckProviderFactory(PlayIntegrityAppCheckProviderFactory.getInstance());
firebaseAppCheck.installAppCheckProviderFactory(DebugAppCheckProviderFactory.getInstance());
build.gradle
implementation 'com.google.firebase:firebase-appcheck-debug:16.1.1'
is there maybe another way to get the local debug token so i can add it in the firebase console?
I have to dynamically check for location permission in my Flutter appliaction,
For that I am using below plugins:
permission_handler: ^10.2.0
location: ^4.4.0
Now, Its needed to check for the permission status i.e. granted, denied, restricted and allowed. So, for that I am declaring PermissionStatus as below:
PermissionStatus locationPermissionStatus = PermissionStatus.denied;
But due to below two imports one is for location and one is for permission,
import 'package:location/location.dart';
import 'package:permission_handler/permission_handler.dart';
It saying me on PermissionStatus declaration:
The name 'PermissionStatus' is defined in the libraries 'package:location_platform_interface/location_platform_interface.dart (via package:location/location.dart)' and 'package:permission_handler_platform_interface/permission_handler_platform_interface.dart (via package:permission_handler/permission_handler.dart)'. (Documentation) Try using 'as prefix' for one of the import directives, or hiding the name from all but one of the imports.
How can I resolve this ambiguity of imported data from two different plugins?
use for import both packages.
import 'package:location/location.dart' as location;
import 'package:permission_handler/permission_handler.dart';
for use location Permission.
location.PermissionStatus locationPermissionStatus = location.PermissionStatus.denied;
I Hope this will solve your issue.
My app was working normally since today.I already included Firebase Storage in my Android Flutter App and it works after that today I get AppCheck Errors suddenly. I was not include App Check for our project or not enforced in settings. After that I was following the official documentation for initialization appcheck : https://firebase.flutter.dev/docs/app-check/usage.
This is my Kotlin MainActivity:
import android.os.Bundle
import com.google.firebase.FirebaseApp
import com.google.firebase.appcheck.FirebaseAppCheck
import com.google.firebase.appcheck.debug.DebugAppCheckProviderFactory
import io.flutter.embedding.android.FlutterActivity
class MainActivity : FlutterActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
FirebaseApp.initializeApp(/*context=*/ this);
val firebaseAppCheck = FirebaseAppCheck.getInstance()
firebaseAppCheck.installAppCheckProviderFactory(
DebugAppCheckProviderFactory.getInstance())
super.onCreate(savedInstanceState)
}
}
and this is my main():
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
await FirebaseAppCheck.instance.activate();
runApp(MyApp());
}
I also added this to my app/build.gradle
dependencies {
implementation 'com.google.firebase:firebase-appcheck-debug:16.0.0-beta01'
}
When I make a request to firebase storage, I would expect something like this in my console:
D DebugAppCheckProvider: Enter this debug secret into the allow list in the Firebase Console for your project: 123a4567-b89c-12d3-e456-789012345678
Instead, I'm getting an error:
2021-11-21 18:11:51.442 2091-3452/com.sekspir.grind4gain W/ExponenentialBackoff: network unavailable, sleeping.
2021-11-21 18:11:53.500 2091-3452/com.sekspir.grind4gain W/StorageUtil: Error getting App Check token; using placeholder token instead. Error: com.google.firebase.FirebaseException: Error returned from API. code: 403 body: App attestation failed.
2021-11-21 18:12:11.136 2091-3633/com.sekspir.grind4gain V/NativeCrypto: SSL handshake aborted: ssl=0xdaa42da8: I/O error during system call, Connection reset by peer
Did I miss something here? I am using a real Android device with flutter debug build.
This is Firestore AppCheck Stats looks both of request income
But in Storage session there are not any request fail or success.
Can you double check that you correctly enabled the enforcement ?
It is required to work with Firebase Storage solutions.
Are you using your app in "PWA" mode or in "Native" mode ?
The Recaptcha may be mandatory depending on how your app is distributed.
await FirebaseAppCheck.instance.activate(
webRecaptchaSiteKey: 'recaptcha-v3-site-key',
);
I'm not sure about your implementation of the appcheck-debug dependency on the Android Native side.
Since it's already implemented by the Flutter library itself, you should remove it.
Personal note : I had troubles with FirebaseAppCheck on some devices, while it was working perfectly on other devices.
This library is still in beta and I would recommend to wait before using it in production.
'final channel = WebSocketChannel.connect(
Uri.parse('wss://echo.websocket.org'),
);'
can create and connect in web application
but can't connect in android emulator
There are two libraries implementing WebSocket class - one that works on web, the other on Andoroid.
You can sort this out by creating a simple factory function. You will need to create several files:
websocket_client_factory.dart
export 'websocket_client_factory_null.dart'
if (dart.library.html) 'websocket_client_factory_web.dart'
if (dart.library.io) 'websocket_client_factory_server.dart';
websocket_client_factory_null.dart
import 'package:web_socket_channel/web_socket_channel.dart';
WebSocketChannel makeWsClient(String url) {
throw 'Platform not supported';
}
websocket_client_factory_server.dart
import 'package:web_socket_channel/io.dart';
import 'package:web_socket_channel/web_socket_channel.dart';
WebSocketChannel makeWsClient(String url) =>
IOWebSocketChannel.connect(url, protocols: ['graphql-ws']);
websocket_client_factory_web.dart
import 'package:web_socket_channel/html.dart';
import 'package:web_socket_channel/web_socket_channel.dart';
WebSocketChannel makeWsClient(String url) =>
HtmlWebSocketChannel.connect(url, protocols: ['graphql-ws']);
Now, from your original file just import the factory file, and call the factory function:
import 'package:./websocket_client_factory.dart';
...
var channel = makeWsClient(wssUrl);
In my project WebSocket connection needs authentication
In web application automatically pass cookies and authentication token in
websocket connection
But in Mobile Application we need to set cookies and authentication
token manually
When I done this resolved my issue
I've been trying to code an Angular2 component with web workers, but I'm having trouble importing code for the worker thread. Here's the start of my component's code:
import {Component} from 'angular2/web_worker/worker';
import {platform} from "angular2/core";
import {WORKER_APP_PLATFORM, WORKER_APP_APPLICATION} from 'angular2/platform/worker_app';
In loader.js, I call importScripts in the following way:
importScripts( "https://code.angularjs.org/tools/system.js",
"https://code.angularjs.org/2.0.0-beta.0/web_worker/worker.dev.js",
"https://code.angularjs.org/2.0.0-beta.0/angular2.min.js",
"../../../../node_modules/reflect-metadata/Reflect.js");
I've verified that loader.js executes, but when I run the application, I get errors stating that "angular2/web_worker/worker", "angular2/core", and "angular2/platform/worker_app" can't be found. Do I need to import different dependencies in loader.js?