I am using the below code to set the background color as black to the container, but it's not showing.
Align(
alignment: Alignment.bottomCenter,
child: Container(
color: Colors.black,
margin: EdgeInsets.only(left: 20, right: 20, bottom: 20, top: 10),
height: 40,
width: double.infinity,
child: RaisedButton(
textColor: Colors.white,
color: Colors.blue[300],
onPressed: () => null,
child: Text('Next'),
),
),
)
Output:
Can somebody please help me?
Easy solution: Wrap it inside container and give it color property.
Container(
color: Colors.black,
child: Align(
alignment: Alignment.bottomCenter,
child: Container(
margin: EdgeInsets.only(left: 20, right: 20, bottom: 20, top: 10),
height: 40,
width: double.infinity,
child: RaisedButton(
textColor: Colors.white,
color: Colors.blue[300],
onPressed: () => null,
child: Text('Next'),
),
),
),
)
I think the problem is that the RaisedButton gets the size of the Container and that's why you are not seeing any black colour. As NetanZaf suggested, You can use a padding so RaisedButton will not get the container size and you will see a black colour.
This is the result of the following code:
Align(
alignment: Alignment.bottomCenter,
child: Container(
color: Colors.black,
margin: EdgeInsets.only(left: 20, right: 20, bottom: 20, top: 10),
padding : EdgeInsets.only(left: 10, right: 10, bottom: 10, top: 10),
height: 40,
width: double.infinity,
child: RaisedButton(
textColor: Colors.white,
color:Colors.blue[300],
onPressed: () => null,
child: Text('Next'),
),
),
),
You can change the values to get the result you want
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With