I want when any key is pressed so it should show in Text
widget(in place of data) [please see below image]. For Example 1 is pressed so 1, then I press 2 so, it should show 12, etc. Then, if I press call end(bottomright button) so, that field should be cleared.
Let me add code below,
Column(
[
Text("data"),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
GestureDetector(
onTap: () {},
child: defaultContainer("1")),
GestureDetector(
onTap: () {},
child: defaultContainer("2")),
GestureDetector(
onTap: () {},
child: defaultContainer("3")),
],
),
.........
],
)
Widget defaultContainer(String value) {
return Container(
width: 60,
height: 60,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(50),
boxShadow: const [BoxShadow(blurRadius: 5)],
color: colors[random.nextInt(8)],
),
child: Center(
child: Text(
value,
style: const TextStyle(fontSize: 30),
)),
);
}
Hope, I could explain.
4
Answers
You can user a String type "data" to save your data: add value to list when press number button, and set data = ” when press call end button.
create a String variable:
then, make sure you are using stateful class and add this inside onTap function:
You need to give the "data" dynamically. Example:
then you can use like this:
You can archive this by declaring a variable to store the number and having a function that appends a digit to the number when pressed.
Try the below snippet: