Reputation: 2381
So I have this constructor and as you can I have all of the parameters set to be required except for the id. This isn't a big deal but I was wondering if there was annotation that would make the id parameter not available to be filled in.
So I don't mess something up in the future and fill the id in by accident, because this is being entered into a database.
Thank you in advance! I'm new to Flutter but am loving it so far and this community rocks! <3
//Constructor
NotifierInstance({
//Identification
this.id,
@required this.symbol,
@required this.companyname,
@required this.exchange,
//Notifier
@required this.page0Input,
@required this.page1Input,
@required this.page0Unit,
@required this.page2Input,
@required this.page2Unit,
@required this.page3Input,
//Logic
@required this.principleDate,
@required this.principlePrice,
});
Upvotes: 0
Views: 31
Reputation: 1896
You can simply leave it out of the constructor. But keep in mind that this means the value of id will always be null
after creating the object until you assign a value to it afterwards.
NotifierInstance({
@required this.symbol,
@required this.companyname,
@required this.exchange,
//Notifier
@required this.page0Input,
@required this.page1Input,
@required this.page0Unit,
@required this.page2Input,
@required this.page2Unit,
@required this.page3Input,
//Logic
@required this.principleDate,
@required this.principlePrice,
});
Upvotes: 1