I am using optional parameters in Flutter, when i use named arguments require keyword is allowed however when i use optional parameters its gives an error.
The code below complains that the parameter is non-nullable and either add a require keyword When i add the require keyword it still complains
TextFormField _textFormBuilder([required String label, required String hint]) {
return TextFormField(
keyboardType: TextInputType.text,
textInputAction: TextInputAction.next,
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: 'label',
hintText: 'hint',
),
);
}
This code below works as expected:
TextFormField _textFormBuilder({required String label, required String hint}) {
return TextFormField(
keyboardType: TextInputType.text,
textInputAction: TextInputAction.next,
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: 'label',
hintText: 'hint',
),
);
}
Any ideas?