Hey, guys. We are working with Flutter and havent been able to entirely determine whats going on but all operations with database seem to not be working:
- How do we make sure the Backendless.initApp() operation is working?
- Also, we thought maybe you released a new version of the SDK but then we realized weve been using version 0.4.0 for a while now but you only show up to version 0.3.0 in your Release History… Is this no longer updated? And is there a new Flutter SDK?
Hey @Samuel_Franco
- Initialization call should not result in error. All consequent requests to your Backendless backend should be recognized
- Sorry, we’ll update the release history with patch notes shortly. At this moment you can use this one - backendless_sdk | Flutter Package
all operations with database seem to not be working
Can you please share error message you are getting? Also provide your application and steps to reproduce the problem
Anton
To reproduce the problem try:
Use this as your main:
import 'package:flutter/material.dart';
import 'package:parki_v5/viewcontrollers/home_page.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'viewcontrollers/registro/iniciar_sesion_page.dart';
import 'dart:async';
import 'package:parki_v5/backendless_files/backendless_variables.dart';
Future<void> main() async {
await startDatabases();
SharedPreferences prefs = await SharedPreferences.getInstance();
var isLoggedIn = prefs.getBool("isLoggedIn") ?? false;
runApp(MaterialApp(home: isLoggedIn ? Home(index: 1) : IniciarSesion()));
}
This is the content of backendless_variables.dart, where we make the app init (it had always worked just fine):
import 'package:backendless_sdk/backendless_sdk.dart';
BackendlessUser userDB;
Map user = {
"ocupando": null,
"phone": null,
"name": null,
"email": null,
"birthDate": null,
"misParqueaderos": null,
"isAdmin": null,
};
String userId;
bool isActiveDB;
const String SERVER_URL = "https://api.backendless.com";
const String APPLICATION_ID = "859418E3-AA83-93D2-FF8E-C0009E704C00";
const String ANDROID_API_KEY = "5DFFBA17-86E9-0937-FF47-EC44F4BAE300";
const String IOS_API_KEY = "47A235D7-A101-9329-FF29-2703AB464C00";
IDataStore<Map> userRef;
IDataStore<Map> parkiRef;
IDataStore<Map> tarjeRef;
IDataStore<Map> caliRef;
IDataStore<Map> transacRef;
bool localDBHasData = false;
bool localDBHasMyParkis = false;
bool localDBHasUsedParkis = false;
void startDatabases() async {
await Backendless.setUrl(SERVER_URL);
await Backendless.initApp(
APPLICATION_ID,
ANDROID_API_KEY,
IOS_API_KEY,
);
if(await Backendless.userService.isValidLogin()) {
userId = await Backendless.userService.loggedInUser();
userDB = await Backendless.userService.findById(userId);
user = {
"ocupando": await userDB.getProperty("ocupando"),
"pagos" : await userDB.getProperty("pagos"),
"historial" : await userDB.getProperty("historial"),
"phone": await userDB.getProperty("phoneNumber"),
"name": await userDB.getProperty("name"),
"email": await userDB.getProperty("email"),
"birthDate": await userDB.getProperty("birthDate"),
"misParqueaderos": await userDB.getProperty("misParqueaderos"),
"isAdmin": await userDB.getProperty("isAdmin"),
};
print(user['email']);
print(user['birthDate']);
print(user['email']);
print(user['phone']);
}
userRef = Backendless.data.of("Users");
parkiRef = Backendless.data.of("Parqueaderos");
tarjeRef = Backendless.data.of("Tarjetas");
caliRef = Backendless.data.of("Calificaciones");
transacRef = Backendless.data.of("Transacciones");
}
Hi, Samuel!
I’ve checked tests for Flutter-SDK and can’t see any problems with it.
Also I’ve connected to your app and haven’t seen any problems with getting data from DB.
Can you specify your problem, what exactly is not working for you now?
Hi @Samuel_Franco
I also created a new project with a code snippets that you provide. Everything works fine for me.
Can you please describe in details what is not working?
I see that you initialize the Backendless, check for valid user and then start the app with home or iniciar screen. What is the actual behavior now? Does the app freezes or crashes? Or are there any errors in logs?
Best Regards,
Maksym