Simply i have to classes child and parent class
i am new in dart language all i need to assign super class properties from child class
this is super class structure
class Trip{
final int id;
final String title;
final double price;
Trip({this.id,this.title,this.price});
}
and this is child class
class FullTrip extends Trip{
final String data;
FullTrip({this.data}) : super(id:id,title:title,price:price);
}
sure this not working at all
the question is : how can i initialize instance from FullTrip and pass variable for FullTrip and Trip(super class)
thanks in advance
Syntax: // To access parent class variables super. variable_name; // To access parent class method super. method_name();
You need to repeat the parameters in the subclass.
class FullTrip extends Trip{
final String data;
FullTrip({this.data, int id, String title, double price}) : super(id:id,title:title,price:price);
}
There are discussions about reducing such boilerplate for constructors, but nothing is decided yet as far as I know.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With