i am trying to implement faceID for android in flutter. My android phone has face unlock feature but unable to detect while running my flutter app in phone. i am using below code :
Future<void> _getListOfBiometricTypes() async {
List<BiometricType> listofBiometrics;
try {
listofBiometrics = await _localAuthentication.getAvailableBiometrics();
} on PlatformException catch (e) {
print(e);
}
if (!mounted) return;
setState(() {
_availableBiometricTypes = listofBiometrics;
print(_availableBiometricTypes.length);
print(_availableBiometricTypes.toString());
});
}
only finger print detected. Why not showing face ID detection?
Related
I'm building an app that requires me to use the camera of the device. I have followed all the procedures to set it up via the Image Picker Documentation and I am still having issues.
Funny enough, it was working fine when I tested it last time but as I added new widgets to screen and tried testing again, the app crashed with very minimal error message which says:
Lost connection to device.
This is how I capture the image:
Future<void> _pickImage() async {
try {
bool isPermisionGranted = await _requestFilePermission();
if (!isPermisionGranted) {
showToast('Please give us access to your camera.');
return;
}
final image = await ImagePicker().pickImage(source: ImageSource.camera, imageQuality: 90);
if (image == null) return;
final tempImageFile = File(image.path);
setState(() {
_imageFile = tempImageFile;
});
if (!mounted) return;
Navigator.of(context).pushNamed(Routes.chi, arguments: {'image_file': _imageFile});
} on PlatformException catch (e) {
debugPrint('Failed to pick image: $e');
showToast('Failed to pick image');
}
}
Could this be a memory issue? And how can I resolve it?
await _audioPlayer!.startPlayer(
fromURI: 'https://URL/TestFiles/sssssssss.acc',
codec: Codec.aacADTS,
);
} catch (e) {
print(e);
}
the exception is platform exceptio error unknown startplayer() error,null .
in the debug console I got these
FlutterSoundPlayer.log (package:flutter_sound/public/flutter_sound_player.dart:500:13
MethodChannelFlutterSoundPlayer.channelMethodCallHandler (package:flutter_sound_platform_interface/method_channel_flutter_sound_player.dart:161:19
I am using real android device
flutter doctor returns everything is good
this remote file works well in angular client
It's played Now I was missing that the file extension is aac not acc
so it should be
await _audioPlayer!.startPlayer(
fromURI: 'https://URL/TestFiles/sssssssss.aac',
);
} catch (e) {
print(e);
}
to play audios i use this library
audioplayers: ^0.19.1
declare this variable to access audio
String audioCorrect = "audio/access_granted.mp3";
String audioInCorrect = "audio/access_denied.mp3";
method for init player
void initPlayer() {
advancedPlayer = new AudioPlayer();
audioCache = new AudioCache(fixedPlayer: advancedPlayer);
}
call initPlayer in initState method
play the audio this way
audioCache.play(audioCorrect);
I have a flutter project (iOS, Android) that uses WebRTC. I need to send video from camera (working correctly) and screen capture by WebRTC. How to share the screen on WebRTC with the flutter_webrtc package?
You can use the flutter_webrtc plugin and do like this method ( use getDisplayMedia method in webRTC to get display ) :
class ScreenSharing {
MediaStream? _localStream;
final RTCVideoRenderer _localRenderer = RTCVideoRenderer();
Future<void> _makeScreenSharing() async {
final mediaConstraints = <String, dynamic>{'audio': true, 'video': true};
try {
var stream = await navigator.mediaDevices.getDisplayMedia(mediaConstraints);
_localStream = stream;
_localRenderer.srcObject = _localStream;
} catch (e) {
print(e.toString());
}
}
}
I'm facing a problem while using the plugins image_picker: "0.6.1+11" and
barcode_scan: "^1.0.0". Firstly I scan a barcode and then take a picture from the camera.
The problem is most of the times the android app restarts itself after taking image from the camera without any log. The log just prints "Lost connection to the device."
Here is the code:
Future scanCarton() async {
try {
String barcode = await BarcodeScanner.scan();
await getImage().then((imageFile){
if (imageFile != null){
Map<String,String>requestData = new Map<String,String>();
requestData["content"] = barcode;
requestData["type"] = "carton";
requestData["mode"] = "job";
if (widget.orderData.product_type.toLowerCase() == "batched"){
requestData["carton_id"] = "0";
}else{
requestData["carton_id"] = "${scannedCartonCount + 1}";
}
if(this.mounted){
setState(() {
_isLoading = true;
});
}else{
print("Gotcha 2");
}
upload(imageFile, UrlFile.UPLOAD_SCAN_IMAGE, "carton", requestData).then((value){
if(this.mounted){
setState(() {
_isLoading = false;
});
}else{
print("Gotcha 4");
}
incrementCartonCount();
if(widget.orderData.product_type.toLowerCase() == "batched"){
openNextCartonPopup();
}
});
}
});
} on PlatformException catch (e) {
if (e.code == BarcodeScanner.CameraAccessDenied) {
print('The user did not grant the camera permission!');
} else {
print('Unknown error $e') ;
}
} on FormatException{
print( 'null (User returned using the "back"-button before scanning anything. Result)');
} catch (e) {
print('Unknown error: $e');
}
}
You just need to configure to ask for permission beforehand.
For iOS, add the following keys to your Info.plist file, located at <project root>/ios/Runner/Info.plist:
NSPhotoLibraryUsageDescription - describes why your app needs permission for the photo library. This is called Privacy - Photo Library Usage Description in the visual editor.
NSCameraUsageDescription - describes why your app needs access to the camera. This is called Privacy - Camera Usage Description in the visual editor.
NSMicrophoneUsageDescription - describes why your app needs access to the microphone, if you intend to record videos. This is called Privacy - Microphone Usage Description in the visual editor.
In the same way, you need to add permissions in Android.
Try your method with dispose()
#override
void dispose() {
[your method name].dispose();
super.dispose();
}
I got the same issue and found the solution. If you have TextField and imager picker in the same page, please make sure the textfield is unfocused (the cursor should be gone from you TextField) when you pick image.
Do something like FocusScope.of(context).requestFocus(new FocusNode()); in your pickImage method.
I need to fetch current location of device in my Flutter App. I have added plugins are location: ^2.3.5 and geolocator: ^5.0.1 to get current location.
All is working fine but when the GPS of my device is off(disabled) then it shows a dialog that i have shown in Image please check it.I need call back on press ok button so that i can get current location and execute next code lines. I will be thankful to you if you help me.
Here have some code.
getCurrentLocation() async{
try {
await location.getLocation().then((locationData){
if(locationData!=null){
moveHomeWithLatLon(context,false,locationData.latitude.toString(),locationData.longitude.toString());
}else{
dialogInternetCheck(context, alert, "Please check location services on device");
}
});
} on PlatformException catch (e) {
if (e.code == 'PERMISSION_DENIED') {
error = 'Permission denied';
dialogInternetCheck(context, alert, "Location services "+error);
}
}
}
You should check for the service status result after requesting location service. If it is true that means the user has provided the access. I have provided the example below
bool serviceStatusResult = await location.requestService();
print("Service status activated after request: $serviceStatusResult");
if (serviceStatusResult) {
await _getCurrentLocation();
}
Future<bool> _getCurrentLocation() async {
try {
Location location = Location();
LocationData userLocation = await location.getLocation();
} on PlatformException catch (e) {
Log.info("Location fetch failed : ${e.toString()}");
}
return Future.value(true);
}