I am trying to build a horizontal button group using flutter but the I didn't get as far as desired, I am new when it comes to building UIs using dart, how can I tweak the code to achieve the desired result ?
Below you will find my current progress and the desired result!
current row of buttons
//Horizontal buttons row
Wrap(
direction: Axis.horizontal,
children: <Widget>[
ButtonTheme(
minWidth: 40.0,
child: RaisedButton(
color: Colors.white,
onPressed: () {},
child: Text("A"),
),
),
ButtonTheme(
minWidth: 40.0,
child: RaisedButton(
color: Colors.white,
onPressed: () {},
child: Text("B"),
),
),
ButtonTheme(
minWidth: 40.0,
child: RaisedButton(
color: Colors.white,
onPressed: () {},
child: Text("C"),
),
),
ButtonTheme(
minWidth: 40.0,
child: RaisedButton(
color: Colors.white,
onPressed: () {},
child: Text("D"),
),
),
ButtonTheme(
minWidth: 40.0,
child: RaisedButton(
color: Colors.white,
onPressed: () {},
child: Text("E"),
),
),
ButtonTheme(
minWidth: 40.0,
child: RaisedButton(
color: Colors.white,
onPressed: () {},
child: Text("F"),
),
),
ButtonTheme(
minWidth: 40.0,
child: RaisedButton(
color: Colors.white,
onPressed: () {},
child: Text("G"),
),
),
],
)
given result:

desired result

Here's how I did it:
Widget specialCharsPanel() {
return Container(
child: Material(
elevation: 4.0,
borderRadius: BorderRadius.all(Radius.circular(6.0)),
child: Wrap(
direction: Axis.horizontal,
children: <Widget>[
SpecialChar("A"),
SpecialChar("B"),
SpecialChar("C"),
SpecialChar("D"),
SpecialChar("E"),
SpecialChar("F"),
SpecialChar("G"),
],
),
),
);
}
you could use ToggleButtons that is more accesible and compatible with tabindex in web and desktop https://api.flutter.dev/flutter/material/ToggleButtons-class.html
https://www.youtube.com/watch?v=kVEguaQWGAY
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