0

I need to check my file reading was successful and return true or false. I need to use async and await function because it needs to return true otherwise no point continuing.

I get a run time error from my snapshot: format.Exception:Invalid boolean false

Offending line is: bool result = await fb.readFile();

enter image description here

More detail image:

enter image description here

4
  • can you provide a working example? for example the definition of fb nor Rung.myList is not part of your example code. otherwise the code looks fine on a first glance. Commented Sep 24, 2023 at 14:16
  • I've added more detailed image of my code Commented Sep 24, 2023 at 14:29
  • try with FutureBuilder, & try to upload code-snippet instead of code-image. More about Why should I not upload images of code/data/errors? Commented Sep 24, 2023 at 14:43
  • 2
    your IDE should mark this code as invalid, already before compiling: bool result = await fb.readFile(); Reason being, that fb is not accesible in an initializer, since fb is initialized at the same time as result is (that being on creation of an A instance). also async code is prolly invalid as an initializer. Commented Sep 24, 2023 at 14:55

1 Answer 1

0

You dont have a return, maybe something like this:

Future<bool> boolFuture()async{
await Future.delayed(Duration(seconds: 1));
return false;
}

Good luck

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.