Trying to use flutter_siren 1.2.0
After I check permissions, I do
Final Siren siren=Siren();
String myver = await siren.localVersion;
But... siren.localversion is... null. I have it in my pubspec.yaml (Android) and the app is published to play store...
What am I missing?
Related
i am working in flutter app,
I want each user to create only one account through his device
That is, banning the device from creating other accounts for two days
After two days, the user can create another account only, and so on,
in my case : save device id or token and date Time in firebase and before create account app check if this device was registered or not if registered check time , this way is right ?
and how can i get device id or any constant number from device ?
thanks
I'm sorry, I think I may not have fully grasped your question, here's my guess about what you are asking based on the agglomeration of English words you've put:
You are using Flutter to develop the front-end of an application while using Firebase for the back-end. You want to make sure that each device could only create one account every 48 hours. Please correct me if my understanding is wrong.
There's never a unique solution to those kind of questions, and I think your approach (timestamp + some ID that tells devices apart) is a decent one.
To get the device ID, it looks like you can use the device_info_plus plugin according to here: How to get unique device id in flutter?
You need to find and store unique device ID in the database.
You can find unique device using this plugin
dependencies:
device_info_plus: ^3.2.3
Create a method:
Future<String?> _getId() async {
var deviceInfo = DeviceInfoPlugin();
if (Platform.isIOS) { // import 'dart:io'
var iosDeviceInfo = await deviceInfo.iosInfo;
return iosDeviceInfo.identifierForVendor; // unique ID on iOS
} else if(Platform.isAndroid) {
var androidDeviceInfo = await deviceInfo.androidInfo;
return androidDeviceInfo.androidId; // unique ID on Android
}
}
How can I get UUID in Flutter Web.
I need some unique identifier in order to keep record of devices useb by customer,my testing device,develeper device.
In android, I'm using device_info_plugin.
How can I get Unique identifier in Web?
Thanks in Advance
You can use platform_device_id to get the browser details.
For browser info, you can use it as
import 'package:platform_device_id/platform_device_id.dart';
String? deviceId = await PlatformDeviceId.getDeviceId;
print($deviceId);
OR
hare is the Answer to the approach to set a custom uuid for flutter web
The function getExternalStorageDirectory() and ApplicationDocumentDirectory() gives the same directory to me that is inside the android folder. I like to create a folder in storage/emulated/0 , i tried explicitly creating it with
Directory('storage/emulated/0').create(); then it says you have no permission. And i gave all the possible permissions and still gets the same result. Is there any way to create a folder in storage/emulated/0 ?
NB: _getPermission returns a bool according to the permission status. This code works well in an emulator but it is not working in an actual device.
takePhoto(BuildContext context) async {
if ( await _getPermission(Permission.manageExternalStorage)){
final image =await picker.pickImage(source: ImageSource.camera);
var newPath = "storage/emulated/0/takephotosaver";
var directory = Directory(newPath).create();
File fileIMage = File(image!.path);
var imageName = DateTime.now().toString();
fileIMage.copy("$newPath/$imageName.jpg");
Navigator.push(context, MaterialPageRoute(builder: (context)=>MyPreview(fileIMage)));
}
}
}
Edit :-
This code is working in android version 9 and below but not working in android 10 and 11. Is there a way to display the image taken by my camera in a separate folder?
Things have changed after android 10. You shouldn't create folders in storage/emulated/0 now. Google is strict about that, and your app may get rejected if you publish your app in Google PlayStore. If you still want to do that then add this permission in your AndroidManifest.xml.
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
And to get the permission from the user do this,
if (await Permission.manageExternalStorage.request().isGranted) {...}
Edit:
Whenever you create a new file the device can't automatically find it. You'd have to manually tell the device to refresh for the files. Before you'd have to refresh all the files in the device for it to get updated which was very inefficient, but now you could just send the path of the file that you want to get updated. You can use the media_scanner plugin to do so.
Or If you wanna do it yourself with kotlin then here's the code,
private fun broadcastFileUpdate(path: String){
context.sendBroadcast(Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,Uri.fromFile(File(path))))
}
I was using firebase_admob package where I could add the test devices IDs with:
var targetingInfo = MobileAdTargetingInfo(
testDevices: <String> [...]
);
But with google_mobile_ads I couldn't find anything similar to that. So, where can I put the test device IDs? Am I only left with using the test Ad unit?
Use updateRequestConfiguration callback on the MobileAds instance, and provide test device IDs.
MobileAds.instance
..initialize()
..updateRequestConfiguration(RequestConfiguration(
testDeviceIds: <String>[],
));
I am building an app using flutter where I want to scan an image(that includes QR image). I am using packages available to read QR codes, but not working for me. Is there any package/solution to read a QR code from an image?
I Tried package:
qr_code_tools: ^0.0.6
Future _getPhotoByGallery() async {
var image = await ImagePicker.pickImage(source: ImageSource.gallery);
String path = image.path;
decode(path);
}
Future decode(String path) async {
print(path);
String data = await QrCodeToolsPlugin.decodeFrom(path);
setState(() {
_data = data;
});
}
I expect the output of QRCode from the selected image of Gallery.
But getting error here:
QrCodeToolsPlugin.decodeFrom(path);//Null, Null something
Even without providing the permission to your external storage, you can still access the gallery as the gallery is native to your device. However, your application will not be able to access the file that the gallery returns since it does not have the necessarry permission. To be sure, go to your app info and see whether the permission for the external storage was given. It is highly probable that you haven't given the permission to access the external storage. There are packages that allow you to check whether a permission was granted and one of them is permission_handler. So whenever you try to access your storage, check the permission first before accessing the gallery.
I might be wrong though.