setUrl or initWebApp are throwing PlatformException

I’m using Flutter for Web (Version: 1.24.0-10.2.pre) and backendless_sdk (Version: 6.2.0).
In my pubspec.yaml I have:
dependencies:
flutter:
sdk: flutter
backendless_sdk: ^6.2.0

In my data model class I’m calling:
WidgetsFlutterBinding.ensureInitialized();
await Backendless.setUrl(serverUrl);//serverUrl = “https://eu-api.backendless.com
await Backendless.initWebApp(applicationId, jsApiKey);

I’m getting the following error:
PlatformException(error, TypeError: Cannot set property ‘serverURL’ of undefined, null, null)

When I remove the setUrl call I’m getting:
PlatformException(error, TypeError: Cannot read property ‘initApp’ of undefined, null, null)

Am I missing some initialization?

Best regards,
Andreas.

Hello @Andreas_Spernol

I’ve created an internal ticket BKNDLSS-24092 to investigate this

Regards, Vlad

Hi Andreas,

I am sure our Flutter experts will chime in, but I believe the setUrl and initWebApp calls are not asynchronous, therefore the await keyword for them doesn’t apply.

Regards,
Mark

Hi Mark, hi Vladimir,

thanks for the very quick response.
I removed the “await” but it doesn’t make a difference. To me the “await” is also correct, since both function return a Future object. Also these two lines were taken from the template project which I’ve generated from the backendless project.
I tried to compile the template project for android and web and it works. But I have to integrate it into an existing project. I created a new package for that. Maybe I missed something in my package project. I noticed that there was no auto generated generated_plugin_registrant.dart file as well.
I guess I’m missing something here.

Best regards,
Andreas.

Hi @Andreas_Spernol

Please make sure to include the reference to the Backendless JS library:

  1. Open your web/index.html file and reference the Backendless JS library at the end of the head tag like that:
<head>
 ... 
<script src="https://api.backendless.com/sdk/js/latest/backendless.min.js"></script> 
</head>

Best Regards,
Maksym

1 Like