I've been facing this issue, I have a mock class with static values for testing. but I am unable to create a list for custom Object class which has no constructor as following.
class Video {
Video(); //this is default constructor
late int id;
late String name;
}
Problem: Now I want to initialize a static list.
final List<Video> videos = [
new Video({id = 1, name = ""}) //but this gives an error.
];
I don't want to change class constructor.
Is there any way to initialize list of custom class without constructor?
var videos = [Video()..id = 1..name = ''];. However, you really should fix the class constructor, especially withlatevariables.