Flutter : LateInitializationError: Field ‘data’ has not been initialized, got error

You don’t want a late variable, you want a nullable one. If you need to check if something is initialized, you should be using a nullable variable instead and your code is already set up to check for null

just change

late MyData data;


MyData? data;


change to

(Visited 3,085 times, 1 visits today)
Spread the love
Categorized as Flutter