Responsive Numeric Grid

166 views
Skip to first unread message

NoobTheOofy Oof

unread,
Nov 4, 2020, 10:50:02 PM11/4/20
to Flutter Development (flutter-dev)

Hello

I am new in flutter and i am trying to create a responsive numeric keypad to take amount input from the user. It looks great when device is in Portrait but not in landscape mode. Below are the screenshots for both:enter image description here

enter image description here

Below is code for my Gridview :

@override
  Widget build(BuildContext context) {
    return GridView.builder(
      shrinkWrap: true,
      padding: const EdgeInsets.all(10),
      itemCount: NUMERIC_BUTTONS.length,
      itemBuilder: (ctx, i) {
        return NumericItem(
          NUMERIC_BUTTONS[i],
          _updateTextbox,
        );
      },
      gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
        crossAxisCount: 3,
        childAspectRatio: 3 / 2,
        crossAxisSpacing: 10,
        mainAxisSpacing: 10,
      ),
    );
  }

And here is for numeric item widget:

    @override
  Widget build(BuildContext context) {
    return RawMaterialButton(
      onPressed: () {
        _doOperation(widget.operation);
      },
      elevation: 2.0,
      fillColor: theme.hexButtonColor,
      child: widget.operation == "BS"
          ? Icon(
              Icons.backspace,
              color: theme.hexButtonTextColor,
            )
          : Text(
              widget.operation,
              style: TextStyle(
                color: theme.hexButtonTextColor,
                fontSize: 30,
              ),
            ),
      padding: EdgeInsets.all(15.0),
      shape: CircleBorder(),
    );
  }

Can you please guide me how i can make this grid to responsive or may be like something these :enter image description here

enter image description here

--
SHAHZAD AHMED KHAN

Graham Dickinson

unread,
Nov 5, 2020, 2:53:14 AM11/5/20
to NoobTheOofy Oof, Flutter Development (flutter-dev)

--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/CAB2YkbrmP2ysuQ1sWhW_g-w32h0TYXd-v5jkmdbrXomWPoRikA%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages