I am trying to create a Flutter app that has a button with a text and icon as label, the icon being placed right of the text. The approach described in this post yields an odd looking button that seems expanded to the width of the app, see this image (link as I am not allowed to attach images):
Button becomes wide when adding a Row widget as child
It is not clear to me which layout widgets to use to tweak the text+image button to be formatted as the plain text button.
The code for producing the above example:
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text(widget.title),
),
body: new Center(
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Text(
'You have pushed the button this many times:',
),
new Text(
'$_counter',
style: Theme.of(context).textTheme.display1,
),
new RaisedButton(
onPressed: _incrementCounter,
child: new Row(
children: <Widget>[
new Text("Button with text and icon!"),
new Icon(Icons.lightbulb_outline)
],
),
),
new RaisedButton(
onPressed: _incrementCounter,
child: new Text("Button with only text")
),
],
),
),
floatingActionButton: new FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: new Icon(Icons.add),
),
);
}
}