Untitled

 avatar
unknown
dart
5 months ago
5.5 kB
2
Indexable
/*
class KeyBoardScreen extends StatefulWidget {
  const KeyBoardScreen({super.key});

  @override
  State<KeyBoardScreen> createState() => _KeyBoardScreenState();
}

class _KeyBoardScreenState extends State<KeyBoardScreen> {
  String test = "";
  final TextEditingController _controller = TextEditingController();
  final FocusNode _focusNode = FocusNode();

  List<List<KeyBoardModel>> tempList = [
    [
      KeyBoardModel(text: '0'),
      KeyBoardModel(text: '1'),
      KeyBoardModel(text: '2'),
      KeyBoardModel(text: '3'),
      KeyBoardModel(text: '4'),
      KeyBoardModel(text: '5'),
    ],
    [
      KeyBoardModel(text: '6'),
      KeyBoardModel(text: '7'),
      KeyBoardModel(text: '8'),
      KeyBoardModel(text: '9'),
      KeyBoardModel(text: '+'),
      KeyBoardModel(text: '-'),
      KeyBoardModel(text: '*'),
    ],
    [
      KeyBoardModel(text: '/'),
      KeyBoardModel(text: '.'),
      KeyBoardModel(text: '('),
      KeyBoardModel(text: ')'),
      KeyBoardModel(text: 'W'),
      KeyBoardModel(text: 'C'),
    ],
    [
      KeyBoardModel(
        text: "delete",
        icon: const Padding(
          padding: EdgeInsets.only(right: 6),
          child: Icon(
            Icons.backspace_outlined,
            color: Color(0xff0D1A54),
          ),
        ),
      ),
      KeyBoardModel(text: 'F'),
      KeyBoardModel(text: 'PF'),
      KeyBoardModel(text: 'PC'),
      KeyBoardModel(
        text: "enter",
        icon: const Padding(
          padding: EdgeInsets.only(left: 6),
          child: Icon(
            Icons.arrow_circle_right_outlined,
            color: Color(0xff0D1A54),
          ),
        ),
      ),
    ],
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Padding(
        padding: const EdgeInsets.symmetric(vertical: 15),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          mainAxisAlignment: MainAxisAlignment.end,
          children: [
            Padding(
              padding: const EdgeInsets.all(16.0),
              child: TextField(
                controller: _controller,
                focusNode: _focusNode,
                onTap: () {
                  FocusScope.of(context).requestFocus(_focusNode);
                },

                readOnly: true,
                // Prevent system keyboard from appearing
                decoration: const InputDecoration(
                  border: OutlineInputBorder(),
                  hintText: 'Tap here to enter text',
                ),
              ),
            ),
            //  Text(test,style: const TextStyle(fontSize: 20 , fontWeight: FontWeight.bold),),
            const SizedBox(
              height: 300,
            ),
            for (int i = 0; i < tempList.length; i++)
              Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  for (int row_i = 0; row_i < tempList[i].length; row_i++)
                    tempList[i][row_i].icon == null
                        ? InkWell(
                            onTap: () {
                              // print("clicked : ${tempList[i][row_i]}");
                              setState(() {
                                _controller.text += tempList[i][row_i].text;
                              });
                            },
                            child: SingleChildScrollView(
                              scrollDirection: Axis.horizontal,
                              child: Container(
                                padding: const EdgeInsets.all(4),
                                height: 45,
                                width: 45,
                                margin: const EdgeInsets.all(4),
                                decoration: BoxDecoration(
                                  color: const Color(0xffEAF2FF),
                                  borderRadius: BorderRadius.circular(5.0),
                                ),
                                child: Center(
                                  child: Text(tempList[i][row_i].text,
                                      style: const TextStyle(
                                        color: Color(0xff0D1A54),
                                        fontSize: 20,
                                      )),
                                ),
                              ),
                            ))
                        : InkWell(
                            onTap: () {
                              setState(() {
                                if (tempList[i][row_i].text == "delete") {
                                  if (_controller.text.isEmpty) {
                                    return;
                                  }
                                  _controller.text = _controller.text.substring(
                                      0, _controller.text.length - 1);
                                } else if (tempList[i][row_i].text == "enter") {
                                  // add code here
                                }
                              });
                            },
                            child: tempList[i][row_i].icon!,
                          ),
                ],
              )
          ],
        ),
      ),
    );
  }
}
*/
Editor is loading...
Leave a Comment