18. Flutter - Widget Classes with Variables and Constructor
Making a widget a stateless widget that has variables that can be initialized in app.
1. Create a stateless widget.
// By stless
// OR
// Clicking on a widget function and extract it using
2. Create a variable that is "final"
final Classname Variablename;
// Classname should be the parameter that goes in the widget parenthesis.
3. Create a constructor for the widget class.
Class({this.variablename});
4. Make sure when initializing a widget, put parameter inside the widget parenthesis.
Comments
Post a Comment