initApp returns Null check error

Task: Add Object With API

My Flutter initialization code:
void initializeApp() async {
String result = ‘OK’;
logger.i(‘Before initApp’);
await Backendless.initApp(
applicationId: appID,
iosApiKey: apiKeyiOS,
androidApiKey: appKeyAndroid,
).onError((error, stackTrace) {
result = error.toString();
logger.w(‘After initApp - result = $result’);
} // initializeApp
initializeApp is first call in main.

initializeApp returns this error message:
Null check operator used on a null value


Hi Jim,

Are you running iOS or Android build? Debug or production?


Android (assume, because selected device is android simulator), in debug.

Hello, @Jim_Austin.

I am unable to reproduce this problem. For me everything works fine on both Android and iOS.
Could you specify in more detail the steps for reproduce?

Best Regards, Nikita.


It appears there may be some not-understood (by me) Flutter issue here.

I noticed the Backendless SDK guide for Flutter shows the initApp call in an
initState() override, so I rewrote by ‘plagiarizing’ the default counter app. InitState is a stateful class method so that’s where I put it. The app now completes the initApp call successfully, and (on button press) saves the data to the ‘Person’ table. Good experience, and useful for the following missions of retrieve, update, and delete.

The project is on Google Drive at

Main.dart is the working code, main_org.dart is the original code that gives the error. I know it’s not your job to ‘teach me Flutter’, but if you have time to look at it and let me know what you think, I’d appreciate it!

I haven’t tried running your project, but looked at its code.

I can assume your error is due to the save api call occurring before your application is initialised. Because you are using asynchronous operations.
You need to wait for initApp to complete its work.

Try the following:

  • Add the async keyword to your main:
    void main() async { // your code }

  • The return type of the initializeApp method must be Future.
    Future initializeApp() async { //your code }

  • On line 7, you need to add the await keyword before using this method. ​
    await initializeApp();

This should fix your problem.

Thanks Nikita, appreciate you taking the time!
Going to finish the CRUD Rookie section with the working code, then work on this ‘bad’ code just for the troubleshooting experience.
Thanks again,