if i have levels of named parameters that needs to be passed down, i don't want to typeout the named parameter for ever method eg,
BaseText(text,options) LargerText(text,options) MenuText(text,options)
eventually i need to pass this to the Text Widget with the different defaults, but to write out all of the parameters, and pass each on down seems like alot of work, how can i get around this.
in JS i would just do
LargerText(text,options){
options = {...defaultOptions,...options}
return BaseText(text,options)
}
Steps to Pass Data to Stateful Widget in Flutter To pass data to stateful widget, first of all, create two pages. Now from the first page open the second page and pass the data. Inside the second page, access the variable using the widget. For example widget.
If Dart supported spreading map into named arguments, this would either reduce type safety, or introduce overhead checks.
Use objects to get around this. This is exactly what objects are for. With each call a compiler checks if the class is what the method expects and so all the fields present. You would not have this with maps.
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