Hi, I’m trying to use Backendless Flutter SDK for Web and I’m getting the following error on initialization:
Backendless plugin for web doesn't implement the method 'Backendless.isInitialized'
Also, querying a table from the Flutter web application doesn’t seem to work, I assume it’s not initializing correctly. The Flutter plugin is `backendless_sdk: ^6.2.0
The SDK seems to be working fine for iOS and Android. Please help!! If I can’t use it with Web I may have to go another direction.
Hi @Justin_Rich ,
thanks for reporting this issue!
I have created an internal ticket (BKNDLSS-24296), one of our engineers will take a look into it asap.
Regards,
Stanislaw
Hi @Justin_Rich
The following method is not implemented for the Web, but it’s not required to call it. Because if the app is not initialized properly the corresponding error will be thrown during Backendless.initWebApp()
call.
If the initWebApp
method result is successful you can be sure the app is initialized correctly.
Also, querying a table from the Flutter web application doesn’t seem to work,
Can you share more details? How do you query the table? What error do you get?
Best Regards,
Maksym
Our application id: 61A6B8E5-4A98-A79E-FF23-4C89AE4A1200
We did add this to the head section in index.html: <script src="https://api.backendless.com/sdk/js/latest/backendless.min.js"></script>
We are initiallizing it like:
if (!kIsWeb) {
print('Is Mobile');
await Backendless.initApp(APPLICATION_ID, ANDROID_API_KEY, IOS_API_KEY);
} else {
print('Is Web');
await Backendless.initWebApp(APPLICATION_ID, JS_API_KEY);
}
print('API Ready.');
And using it like:
Future getPosts() async {
print(await Backendless.isInitialized());
try {
DataQueryBuilder queryBuilder = DataQueryBuilder()
..sortBy = ['created DESC'];
List<Map<dynamic, dynamic>> posts =
await Backendless.data.of("Post").find(queryBuilder);
posts.forEach((value) {
final post = Post(
user_id: value['user_id'],
location: value['location'],
message: value['message'],
in_person: value['in_person'],
);
_posts.add(post);
});
} catch (error) {
print('Error: $error');
}
}
With that print(await Backendless.isInitialized());
we were seeing the error we discussed above. Once I remove that I still just get back no records and I’m seeing an error that doesn’t tell me anything: Error: PlatformException(error, Invalid argument: Instance of 'NativeJavaScriptObject', null, null)
I can’t tell if it’s directly related or is as a result of receiving no results and failing further down the line.
I don’t have any of these issues in iOS or Android. I would like to be able to use this app in web and possibly electron down the road, so I need this Web SDK to work.
We found out the error is caused by location
field. Seems like geometry is not currently supported for Web. I’ve updated the internal ticket (BKNDLSS-24296). And we will fix this issue as soon as possible.
For now you can exclude this property using following code:
DataQueryBuilder queryBuilder = DataQueryBuilder()
..sortBy = ['created DESC']
..excludeProperties = ['location'];
Best Regards,
Maksym
Ok, I have confirmed that this temporary patch does fix the query. I can find and save records if I don’t include location in the object. Please keep me posted. Thx!!
Hi Maksym, I’d like to check in on this issue. Has the team made any progress on it?
Thank you!
Justin
Hi @Justin_Rich
We expect to release a new version of Flutter SDK till the end of this week. We will notify you about it
Best Regards,
Maksym
Hi @Justin_Rich
The issue has been resolved. Please check new Flutter SDK release v.6.3.0. Notice that spatial data types for Web are received as Map objects due to technical specifications.
In your code
location: value['location'],
the type of value['location']
will be Map. You can manually convert it to the desired geo type.
Best Regards,
Maksym
@Maksym_Khobotin2 thank you!!! I will give it a run through as soon as I can!! Nice work!