I/FilePickerDelegate(10329): User cancelled the picker request - android

I am using Flutter in VSCode with Android Emulator. I've encountered a problem where FilePicker won't show any pictures where it should. I am new in this area and I am following a tutorial - for him everything works normally but for me no. Can someone please help me?
utils.dart
Future<List<File>>pickImages() async {
List<File> images = [];
try{
var files = await FilePicker.platform.pickFiles(
type: FileType.any,
allowMultiple: true,
);
if (files != null && files.files.isNotEmpty) {
for(int i = 0; i < files.files.length; i++){
images.add(File(files.files[i].path!));
}
}
} catch(e) {
debugPrint(e.toString());
}
return images;
}
add_product_screen.dart
void selectImages() async {
var res = await pickImages();
setState(() {
images = res;
});
}
Further in Scaffold I am just calling selectImages with onTap.

Related

mediafilepicker cannot display pdf files

I'm currently using the nativescript-mediafilepicker to upload files. I want the user to pick files regardless of the file extension but the only file shwon by the application is a jpg file. What seems to be the problem here?
public openCustomFilesPicker() {
let extensions = [];
if (Application.ios) {
extensions = [kUTTypePDF, kUTTypeText];
} else {
extensions = ["txt", "pdf", "jpg"];
}
let options: FilePickerOptions = {
android: {
extensions: extensions,
maxNumberFiles: 2,
},
ios: {
extensions: extensions,
multipleSelection: true,
hostView: this._hostView,
},
};
let mediafilepicker = new Mediafilepicker();
mediafilepicker.openFilePicker(options);
mediafilepicker.on("getFiles", function (res) {
let results = res.object.get("results");
console.dir(results);
if (results) {
for (let i = 0; i < results.length; i++) {
let result = results[i];
console.log(result.file);
}
}
});
mediafilepicker.on("error", function (res) {
let msg = res.object.get("msg");
console.log(msg);
});
mediafilepicker.on("cancel", function (res) {
let msg = res.object.get("msg");
console.log(msg);
});
}

APIs won't load when published on Google Playstore

So this is my first time publishing a Flutter app to the Google Play Store. I wanted to create something simple so I could learn the entire process. So I created a simple Trivia App.
When I run the app from my phone or emulator (Android or iPhone) the free API that I'm using here loads the categories without any issues.
The issue I'm having is when I publish the app to the Play Store, the API doesn't load and I don't even get an error message. Just a blank screen.
Here is the API service call in my app:
static Future<List<Category>> fetchCategories() async {
const url = "https://opentdb.com/api_category.php";
var response;
try {
response = await http.get(url);
if (response.statusCode == 200) {
var jsonString = response.body;
final Map<String, dynamic> responseData = json.decode(jsonString);
var list = responseData['trivia_categories'] as List;
var _items = list.map((i) => Category.fromJson(i)).toList();
return _items;
} else {
return null;
}
} on Exception {
throw response.statusCode;
}
}
And this is the code in the controller that calls the API's method.
void fetchCategories() async {
// flag as loading.
isLoading(true);
try {
//get categories from API server
var categories = await ApiServices.fetchCategories();
if (categories != null) {
categories.forEach((Category categoryItem) async {
// adjust data accordingly
categoryItem.totalQuestions =
await fetchCategoryCount(categoryItem.id);
if (userDataController.data.read(categoryItem.id.toString()) !=
null) {
// get a list of answered questions from the device and count them
List<dynamic> correctAnswers =
userDataController.data.read(categoryItem.id.toString());
categoryItem.correctAnswers = correctAnswers.length;
} else {
categoryItem.correctAnswers = 0;
}
categoryTiles.add(categoryItem);
});
}
} on Exception catch (e) {
throw new Exception("An error occured fetching the data");
} finally {
isLoading(false);
}
}
Has anyone else ran into this issue?

Why can't I connect to an API when I generate the APK?

I have a problem with a login that I am doing, in my emulator it works correctly but when I generate the apk and test it on the phone, the API does not work.
I already assigned the Internet permission in the .xml and made tests to use Internet images and everything fine, so I discarded the permissions.
I do not know if it gives me an error because I use an http and not an https, or if someone has an idea of ​​what is happening here they tell me, I attach my code
Code:
void _login(BuildContext context) async {
if (!_loading) {
setState(() {
_loading = true;
});
}
//print(_username.value.text);
//print(_password.value.text);
var url = Uri.parse(
"http://taquillamedicina.mdgsystem.com/index.php?route=api/loginapp");
String var1 = 'vipmedico';
String var2 =
'xxxxx';
SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
Map data = {
'username': var1,
'password': var2,
'usernameapp': _username.value.text,
'passwordapp': _password.value.text
};
var jsonResponse = null;
var response = await http.post(url, body: data);
//print(response);
if (response.statusCode == 200) {
jsonResponse = json.decode(response.body);
// print(jsonResponse);
if (jsonResponse != null) {
setState(() {
_loading = false;
});
sharedPreferences.setString("client_id", jsonResponse['client_id']);
if (jsonResponse['error'] == '1') {
Navigator.of(context).pushReplacementNamed("/list");
}
}
} else {
setState(() {
_loading = false;
});
print(response.body);
}
}
To get over this, you will have add android:usesCleartextTraffic="true" to your AndroidManifest.XML file. But as advised, this isn't solving th eproblem, it's sweeping it under the carpet, but will get your task done for now.
After I upgrade the Flutter 2.0 my app is down and I add under Anroid>Src>Main>AndroidManifest.xml
android:usesCleartextTraffic="true"
API and app is worked

How to return Future<object> and assign it to just object , flutter

I have a custom class that fetches data from the database, that returns Future<List<Line>>, which lies in line_list.dart files :
Future<List<Line>> fetchingLinesData() async {
List<Line> lineList = [];
var databasesPath = await getDatabasesPath();
String path = join(databasesPath, 'main.db');
Database database = await openDatabase(path, version: 1);
database.transaction((tnx) async {
dbRef.child('line').once().then((DataSnapshot dataSnapshot) async {
dataSnapshot.value.forEach((key, value) async {
List<Station> inLineStations = [];
for (var i = 0; i < 100; i++) {
if (value["station_$i"] != null) {
List<Map> stations = await tnx.rawQuery("SELECT * FROM Station");
stations.forEach((s) {
if (s['stationName'] == value["station_$i"]) {
Station stationInstance = Station(
key: s['key'],
cityName: s['cityName'],
stationName: s['stationName'],
stationLongitude: s['stationLongitude'],
stationLatitude: s['stationLatitude']);
inLineStations.add(stationInstance);
}
});
}
}
Line lineInstance = Line(
startStation: value['start_station'],
endStation: value['end_station'],
inLineStations: inLineStations,
notes: value['notes'],
price: value['price'],
transportationType: value['transportation_type']);
lineList.add(lineInstance);
});
});
});
return lineList;
}
}
and then in my main.dart widget, I have this :
List<Line> allLines = [];
I want to do something like this :
allLines = LinesList().fetchingLinesData();
But of course, it gives me an error as am trying to assign Future<List<Line>> to List<Line>
how to do it?
You have to await for future to complete.
allLines = await LinesList().fetchingLinesData();
You would just put the code below in a async function make main async and make your code
allLines = await LinesList().fetchingLinesData();

CardIO Plugin - Issues with manually entering Card details on Android

I have implemented the following CardIO plugin in my Ionic App:
https://github.com/card-io/card.io-Cordova-Plugin
This works fine on iOS. However, on Android, when I use the keyboard option in the Camera Screen to manually type in the card details, it first loads the correct screen momentarily, and then jumps back to the first screen (Sign Up screen in this case) of the app. While debugging the app flow, I saw that the callback for Card IO is working fine, but there seems to be an issue when Ionic handles the event.
Any help greatly appreciated!
Following is the code in my controller:
$scope.$on('$ionicView.beforeEnter', function()
{
$scope.creditCardScanning();
}
$scope.creditCardScanning = function(){
var cardIOResponseFields = [
"cardType",
"redactedCardNumber",
"cardNumber",
"expiryMonth",
"expiryYear",
"cvv",
"postalCode"
];
var onCardIOComplete = function(response) {
for (var i = 0; i < cardIOResponseFields.length; i++) {
var field = cardIOResponseFields[i];
}
var cardName = response[cardIOResponseFields[0]].toUpperCase();
for (i = 0; i < $scope.cardtype.length; i++) {
var cardTypeDict = $scope.cardtype[i];
if(cardTypeDict.card_type_name === cardName){
document.getElementById('cardtype').selectedIndex = i;
$scope.params.card_type = cardName;
break;
}
}
document.getElementById('cardNumber').value = response[cardIOResponseFields[2]];
$scope.params.card_number = response[cardIOResponseFields[2]];
var expMonthVal = response[cardIOResponseFields[3]];
for(i=0;i < $scope.expmonth.length; i++) {
var expMonthDict = $scope.expmonth[i];
if(expMonthDict.value === expMonthVal){
document.getElementById('expmonth').selectedIndex = i;
$scope.params.expiration_month = expMonthDict.value;
break;
}
}
for (i = 0; i < $scope.expyear.length; i++) {
var expYearDict = $scope.expyear[i];
if(expYearDict.value === response[cardIOResponseFields[4]]){
document.getElementById('expyear').selectedIndex = i;
$scope.params.expiration_year = response[cardIOResponseFields[4]];
break;
}
}
document.getElementById('cvv').value = response[cardIOResponseFields[5]];
$scope.params.security_code = response[cardIOResponseFields[5]];
};
var onCardIOCancel = function() {
console.log("card.io scan cancelled");
};
var onCardIOCheck = function (canScan) {
console.log("card.io canScan? " + canScan);
var scanBtn = document.getElementById("scanBtn");
if (!canScan) {
console.log("Cannot scan card");
}
scanBtn.onclick = function (e) {
CardIO.scan({
"requireExpiry": true,
"requireCVV": true,
"requirePostalCode": false,
"shows_first_use_alert": true,
"disable_manual_entry_buttons": false
},
onCardIOComplete,
onCardIOCancel
);
}
};
CardIO.canScan(onCardIOCheck);
}
And in my view, I am calling the function to load the next page, once the card details are successfully entered and the "Next" Button is tapped.

Categories

Resources