I am calling the X, Y, Z data in numerical format from the accelerometer. I am able to call this data without issue after the app is launched. On app launch I get the following error:
The getter 'toStringAsFixed' was called on null.
Receiver: null
Tried calling: toStringAsFixed
x1.toStringAsFixed
is called in a TableRow-child-Text field. Because flutter/dart is asynchronous I am sure this error is called because the app tries to display the accelerometer data before it is avalible.
I am unsure of how to delay calling the Text field until data has been populated. I have tried using if == null
statements etc, but none of my attempts has fixed this error.
I had added if (y1.toStringAsFixed == null)
for each of the 3 axis in an attempt to fix the null error. I tweaked this code to be if (y1 == null)
for each axis and now the error has been fixed.
I see that by calling null on the toStringAsFixed
that it is still trying to pull data to check if that data is null, not checking to see if what it will pull is null.