Flutter : LateInitializationError: Field ‘data’ has not been initialized

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;

to

MyData? data;

E.g.

change to

参考链接


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

发布者

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注