[英]How can I remove or disable some objects from class in flutter to use it on another pages
In my flutter app, I made a class to use it on other pages that have the same objects, but on other pages, not all those objects on it.在我的 flutter 应用程序中,我制作了一个 class 以在具有相同对象的其他页面上使用它,但在其他页面上,不是所有这些对象。
class ListItem extends StatelessWidget {
const ListItem(
{Key? key,
required this.nu_image,
required this.en_text,
required this.ja_text,
required this.ja_image,
required this.sound,
required this.color})
: super(key: key);
final String nu_image;
final Color color;
final String en_text;
final String ja_text;
final String ja_image;
final String sound;
How can I remove or disable it to use it on other pages has those objects on it?如何删除或禁用它以在其他页面上使用它有这些对象? for examble: "ja_image".例如:“ja_image”。 Thanks in advance...提前致谢...
If I understand correctly you simply need a question mark?如果我理解正确,您只需要一个问号吗? after data type like so final String? nu_image;
在像这样的final String? nu_image;
final String? nu_image;
. . and remove the required
keyword from the constructor.并从构造函数中删除required
关键字。 That way you can create instance of this class without all parameters needed.这样,您无需所有参数即可创建此 class 的实例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.