Boolean expression must not be null?

前端 未结 4 1100
慢半拍i
慢半拍i 2021-01-23 20:46

Does anyone know why i got the Failed assertion: boolean expression must not be null. If I had logged in and quit the app and open the app again i should be directly in the home

4条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-23 20:47

    Your issue most likely lies in this function where you're setting userIsLoggedIn to null. Ensure getUserLoggedInSharedPreference actually returns a boolean and not null.

      void getLoggedInState() async {
        final result = await HelperFunction.getUserLoggedInSharedPreference();
        if (result != null) {
          setState(() {
            userIsLoggedIn = result;
          });
        } else {
          print("result is null");
        }
      }
    

提交回复
热议问题