xxxxxxxxxx
class TextInputWithIcon extends StatefulWidget {
final String iconPath;
final String placeHolder;
final Function(bool)? onFocusChange; // nullable and optional
const TextInputWithIcon(
{Key? key,
required this.iconPath, // non-nullable and required
this.placeHolder = "", // non-nullable but optional with a default value
this.onFocusChange, // nullable and optional
})
: super(key: key);
@override
_TextInputWithIconState createState() => _TextInputWithIconState();
}
https://levelup.gitconnected.com/3-types-of-dart-parameters-and-using-them-correctly-61d4204d53a5#69be
xxxxxxxxxx
void greet(String name, {String prefix = 'Hello'}) {
print('$prefix, $name!');
}
void main() {
greet('Alice'); // Output: Hello, Alice!
greet('Bob', prefix: 'Hi'); // Output: Hi, Bob!
}