Guys,why it is an obligation to put the 'required' keyword when creating named constructors? How can i create named constructors without being required thought?
class IconPage extends StatelessWidget {
IconPage({required this.icon,required this.label});
final String label;
final IconData icon;
@override
Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
icon,
color: Colors.white,
size: 70,
),
SizedBox(height: 10),
Text(
label,
style: kStandartFontSize,
),
],
);
}
}
Here's the error message that apears when i try to create named constructors without the required keyword:
The parameter 'label' can't have a value of 'null' because of its type, but the implicit default value is 'null'. Try adding either an explicit non-'null' default value or the 'required' modifier.