I want to create something like this:
But obviously, I'm not very successful!
How can I resize the FlatButtons, to fill the entire container, like in the first picture? I know, the solution with the height in the container isn't so good, but that's another problem.
import 'package:flutter/material.dart';
class CalcButton extends StatelessWidget {
//Constructor isn't important for you.
@override
Widget build(BuildContext context) {
if (text == null) {
return FlatButton(
onPressed: () => {}, child: statelessWidget, color: backgroundColor);
} else
return FlatButton(
onPressed: () => {},
child: Text(text,
style: TextStyle(fontSize: fontSize, color: textColor)),
color: backgroundColor);
}
}
My widget is called from down here:
Widget numpad_structure(BuildContext context, var height) {
return Padding(
padding: const EdgeInsets.only(top: 25),
child: Container(
alignment: Alignment.bottomCenter,
width: double.infinity,
height: 550,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: numpad_background_color),
child: numpad_buttons(context, height)
));
}
Widget numpad_buttons(BuildContext context, var height) {
return Column(children: [
Row(children: [
CalcButton(text: "AC", backgroundColor: Colors.red, fontSize: numPadCharacterSize, textColor: textColor),
CalcButton(backgroundColor: Colors.red, statelessWidget: Icon(Icons.backspace_outlined, size: numPadCharacterSize, color: textColor)),
CalcButton(text: "%", backgroundColor: Colors.red, fontSize: numPadCharacterSize, textColor: textColor),
CalcButton(text: "÷", backgroundColor: Colors.red, fontSize: numPadCharacterSize, textColor: textColor)
],
mainAxisAlignment: MainAxisAlignment.spaceEvenly,),
Row(children: [
CalcButton(text: "7", backgroundColor: Colors.red, fontSize: numPadCharacterSize, textColor: textColor),
CalcButton(text: "8", backgroundColor: Colors.red, fontSize: numPadCharacterSize, textColor: textColor),
CalcButton(text: "9", backgroundColor: Colors.red, fontSize: numPadCharacterSize, textColor: textColor),
CalcButton(text: "×", backgroundColor: Colors.red, fontSize: numPadCharacterSize, textColor: textColor)
],
mainAxisAlignment: MainAxisAlignment.spaceEvenly,),
Row(children: [
CalcButton(text: "4", backgroundColor: Colors.red, fontSize: numPadCharacterSize, textColor: textColor),
CalcButton(text: "5", backgroundColor: Colors.red, fontSize: numPadCharacterSize, textColor: textColor),
CalcButton(text: "6", backgroundColor: Colors.red, fontSize: numPadCharacterSize, textColor: textColor),
CalcButton(text: "-", backgroundColor: Colors.red, fontSize: numPadCharacterSize, textColor: textColor)
],
mainAxisAlignment: MainAxisAlignment.spaceEvenly,),
Row(children: [
CalcButton(text: "1", backgroundColor: Colors.red, fontSize: numPadCharacterSize, textColor: textColor),
CalcButton(text: "2", backgroundColor: Colors.red, fontSize: numPadCharacterSize, textColor: textColor),
CalcButton(text: "3", backgroundColor: Colors.red, fontSize: numPadCharacterSize, textColor: textColor),
CalcButton(text: "+", backgroundColor: Colors.red, fontSize: numPadCharacterSize, textColor: textColor)
],
mainAxisAlignment: MainAxisAlignment.spaceEvenly,),
Row(children: [
CalcButton(text: ",", backgroundColor: Colors.red, fontSize: numPadCharacterSize, textColor: textColor),
CalcButton(text: "0", backgroundColor: Colors.red, fontSize: numPadCharacterSize, textColor: textColor),
CalcButton(text: "()", backgroundColor: Colors.red, fontSize: numPadCharacterSize, textColor: textColor),
CalcButton(text: "=", backgroundColor: equal_button_background_color, fontSize: numPadCharacterSize, textColor: textColor)
],
mainAxisAlignment: MainAxisAlignment.spaceEvenly,)
],
mainAxisAlignment: MainAxisAlignment.spaceEvenly,);
}```



