Instead of putting the `RaisedButton` in a `ConstrainedBox`, you can wrap it in an `Expanded` widget within a `Row` like this:
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: SafeArea(
child: Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
TextFormField(),
TextFormField(),
Row(
children: <Widget>[
Expanded(
child: RaisedButton(child: Text("button"), onPressed: () {}),
),
],
),
],
),
),
),
),
);
}
}
The `Row` will create a horizontal row, and the `Expanded` widget will make sure its child will fill as much space as possible.
After some research, I found out some solution, and thanks to @Günter Zöchbauer,
I used column instead of Container and
set the property to column **CrossAxisAlignment.stretch** to Fill match parent of Button
new Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
new RaisedButton(
child: new Text(
"Submit",
style: new TextStyle(
color: Colors.white,
)
),
colorBrightness: Brightness.dark,
onPressed: () {
_loginAttempt(context);
},
color: Colors.blue,
),
],
),