A Brief But Accurate Documentation, BSD Linux And Programming

 Docker

Tuesday, September 13, 2022

bad state no element - Flutter




 As the tittle implied, I've got an error message that it says "Bad state: No element The relevant error-causing widget was CustomPaint"

I made custom circle path with pathmetric my code was 
                                          var metric = extractPath.computeMetrics().first;
            

the '.first' method is the suspected to lead an error, you have to use firstWhere method like the following example:

    
var metric = extractPath

              .computeMetrics()

              .firstWhere((element) => true, orElse: () => pathMetric);

Source codegrepper says to do it like so
someIterable.firstWhere(test, orElse: () => null);

No comments:

Post a Comment

Back to top