Reputation: 960
Below is a snippet of my code:
class _MyHomePageState extends State<MyHomePage> {
Widget buildButton(String buttonText) {
return Expanded(
child: new OutlineButton(
padding: EdgeInsets.all(24.0),
child: new Text(buttonText),
style: TextStyle(fontWeight: FontWeight.bold),
onPressed: () => {},
),
);
}
I am getting the following error:
lib/main.dart:30:7: Error: No named parameter with the name 'style'.
style: TextStyle(fontWeight: FontWeight.bold),
^^^^^
Context: Found this candidate, but the arguments don't match.
const OutlineButton({
^^^^^^^^^^^^^
I am new to flutter and don't know what is wrong with my style statement.
Upvotes: 1
Views: 4409
Reputation: 1288
As mentioned by @Nilesh Rathod, the style
property is in Text
widget and not in OutlineButton
widget.
Also avoid using new
keyword as it is optional. Use trailing commas so that dartfmt
in IDE will format code for you.
Widget buildButton(String buttonText) {
return Expanded(
child: OutlineButton(
padding: EdgeInsets.all(24.0),
child: Text(
buttonText,
style: TextStyle(fontWeight: FontWeight.bold),
),
onPressed: () => {},
),
);
}
Upvotes: 2
Reputation: 69699
The style:TextStyle()
argument is of Text
widgets not of OutlineButton
widgets
You need to add style
argument in Text
widgets
SAMPLE CODE
class _MyHomePageState extends State<MyHomePage> {
Widget buildButton(String buttonText) {
return Expanded(
child: new OutlineButton(
padding: EdgeInsets.all(24.0),
child: new Text(buttonText,style: TextStyle(fontWeight: FontWeight.bold),),
onPressed: () => {},
),
);
}
Upvotes: 2