Import ambiguity for PermissionStatus in Flutter - flutter

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.

Related

firebase/flutter - App Check debug provider in an emulator

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?

Flutter WebSocket works in web application but not in android emulator

'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

How to import a custom AWS rule

I'm trying to import a rule that looks like this in AWS:
enter image description here
I tried a command like this but it fails:
terraform import aws_security_group_rule.ke_ingress_icmp sg-0af205c29967e5084_ingress_icmp_-1_-1_0.0.0.0/0
aws_security_group_rule.ke_ingress_icmp: Importing from ID "sg-0af205c29967e5084_ingress_icmp_-1_-1_0.0.0.0/0"...
aws_security_group_rule.ke_ingress_icmp: Import prepared!
Prepared aws_security_group_rule for import
aws_security_group_rule.ke_ingress_icmp: Refreshing state... [id=sg-0af205c29967e5084_ingress_icmp_-1_-1_0.0.0.0/0]
Error: Cannot import non-existent remote object
I'm not sure how to represent protocol="Destination Unreachable" and port range="fragmentation required, and DF flag set" in the import command. Does anyone have any ideas?

MissingPluginException for getApplicationDocumentsDirectory in flutter tests

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)

Using react-router w/ brunch/babel

I'm attempting use react-router in my brunch/babel setup. In my app.js I have:
import React from "react"
import ReactDOM from "react-dom"
import { Router, Route, Link } from "react-router"
This however gives me:
Uncaught Error: Cannot find module "history/lib/createHashHistory" from "react-router/Router"
When looking at the referenced line I see:
var _historyLibCreateHashHistory = require('history/lib/createHashHistory');
When inspecting the app.js that's generated via brunch I see:
require.register('history/createBrowserHistory', function(exports,req,module) {
...
});
How do I go about fixing this so that createBrowserHistory gets imported properly?
The module history is listed as a peer dependency by react-router, which means that you need to install it yourself through the command npm install history --save.