New programmer here, I'm trying to add a List object to a list within another class but it keeps giving me an error.I've been stuck on this problem for hours now
void main()
{
List<Hobbies> hobby;
Hobbies hobbies = new Hobbies("Football");
hobby.add(hobbies);
User user1 = new User("Harris", 22, hobby);
print(user1.getAge());
}
class User
{
String name;
int age;
List<Hobbies> hobbies;
User(String name, int age, List<Hobbies> hobbies)
{
this.name = name;
this.age = age;
this.hobbies = hobbies;
}
getAge()
{
print(name);
}
}
class Hobbies
{
String name;
Hobbies(String name)
{
this.name = name;
}
getAge()
{
print(name);
}
}
The error i keep getting
TypeError: C.JSNull_methods.add$1 is not a functionError: TypeError: C.JSNull_methods.add$1 is not a function