What is the problem?
The button is located on the background of the gradient and takes its color and i can't change the color..
Maybe the problem is in the gradient? Although I tried to remove the decoration of the container, it did not help. Maybe it's a container?
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
body: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [Colors.black, Colors.blue]),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Padding(...),
CircularPercentIndicator(...),
Padding(...),
SizedBox(height: 20),
Padding(
padding: EdgeInsets.only(bottom: 30.0),
child: ElevatedButton(
child: Text("Start destroying"),
onPressed: null,
style: ElevatedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30.0),
),
primary: Colors.black,
padding: EdgeInsets.symmetric(horizontal: 60, vertical: 15),
textStyle: TextStyle(
fontSize: 25,
color: Colors.white,
),
),
),
),
],
),
),
);
}
You need to set a non-null onPressed
function for the ElevatedButton
:
ElevatedButton(
child: Text("Start destroying"),
onPressed: () {}, // add this
style: ElevatedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30.0),
),
primary: Colors.red,
padding: EdgeInsets.symmetric(horizontal: 60, vertical: 15),
textStyle: TextStyle(
fontSize: 25,
color: Colors.white,
),
),
),
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.