I got the following code and want to make it work:
RaisedButton(
child:
Text(_authMode == AuthMode.Login ? 'LOGIN' : 'SIGN UP'),
onPressed: _submit,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30),
),
padding:
EdgeInsets.symmetric(horizontal: 30.0, vertical: 8.0),
color: Theme.of(context).primaryColor,
textColor: Theme.of(context).primaryTextTheme.button.color,
),
I tried to change it to some point as the following:
ElevatedButton(
child:
Text(_authMode == AuthMode.Login ? 'LOGIN' : 'SIGN UP'),
onPressed: _submit,
style: ButtonStyle(
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30),
)
)
),
padding:
EdgeInsets.symmetric(horizontal: 30.0, vertical: 8.0),
color: Theme.of(context).primaryColor,
textColor: Theme.of(context).primaryTextTheme.button.color,
),
But I don’t know what to do with padding
, color
, and textColor
?
2
Answers
Here’s how to convert the
RaisedButton
to anElevatedButton
.On the
ElevatedButton
use:textColor
use theTextStyle
on theText
widget.shape
, use thestyle
property.color
, use thestyle
property.padding
, use thestyle
property.Your code should look like this:
See also:
Create a rounded button / button with border-radius in Flutter
New Buttons and Button Themes – (Flutter.dev)
Try this