0

I'm making an edit profile page in my flutter app using laravel as my database. I got an error saying that my boolean expression must not be null. How would I be able to solve this?

void _update()async {

setState(() {
  _isLoading = true;
});
var userData;

var update = await Network().editData(userData, '/user Data');
var body = json.decode(update.body);
if(body['Done']){
  SharedPreferences localStorage = await SharedPreferences.getInstance();
  localStorage.setString('user Data', json.encode(body['user Data']));



  Navigator.push(
    context,
    new MaterialPageRoute(
        builder: (context) => Profile()
    ),
  );
}

setState(() {
  _isLoading = false;
});

} }

Here is the stacktrace:

E/flutter (28905): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)]
Unhandled Exception: Failed assertion: boolean expression must not be null
E/flutter (28905): #0 _EditState._update (package:project1app/screen/editprofile.dart:264:12)
2

1 Answer 1

1

This problem occurs when one of your defined boolean type variable is not initialized with default value, for example maybe you have you bool _isLoading; is not defined as should bool _isLoading = false; or bool _isLoading = true;

Sign up to request clarification or add additional context in comments.

2 Comments

Hi i know its already right but can you like tell us what to do so we can solve it. he almost has the same code as mine so please help me.
@xAtifx you need to initialize _isLoading value either set it to true or false

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.