How to set ElevatedButton width. I tried Wrap ElevatedButton with SizedBox set width and Width container but it didn’t work. I also set the minimumSize in the ElevatedButton still can’t change the width of the button. Can anyone help me?
Code:
bottomNavigationBar: Container(
width: 20,
padding: const EdgeInsets.all(20),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
elevation: 0.0,
onPrimary: _buttonIsActive ? Colors.white : const Color(0xFF91A5B2),
primary:
_buttonIsActive ? Color(0xFF0E71B0) : const Color(0xFFE1EAF0),
minimumSize: const Size(88, 56),
padding: const EdgeInsets.symmetric(horizontal: 16),
//padding: EdgeInsets.fromLTRB(10, 5, 10, 5),
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(10)),
),
),
onPressed: () {}, //=> _addVital(), (Need Open)
child: const Text('Update',
style: TextStyle(fontSize: 18, fontWeight: FontWeight.w600)),
),
),
2
Answers
You can wrap the button with Align widget, this will reduce the constraint.
onPrimary
andprimary
are deprecated.2)wrap this container inside Row()