Skip to content
This repository has been archived by the owner on Jan 19, 2023. It is now read-only.

More of a Question than an issue - how to add text below the icon? #13

Closed
pedez opened this issue Apr 23, 2020 · 2 comments
Closed

More of a Question than an issue - how to add text below the icon? #13

pedez opened this issue Apr 23, 2020 · 2 comments

Comments

@pedez
Copy link

pedez commented Apr 23, 2020

I tried to create a Column widget with the Icon and the Text widget, but then the button would be placed in a random place far away from where it was supposed to. I even tried the column as a child of the RawMaterialButton, but same result.

Is it possible to add text below the icon with this package? I would love know. Great package thanks for the content!

@fusion44
Copy link

You can use a Stack for this. I use this helper function:

  Widget _buildIconButtonWithText(
    Function onPressed,
    String text,
    String tooltip,
  ) {
    return Container(
      width: 68,
      height: 55,
      child: Stack(
        children: [
          Align(
            alignment: Alignment.bottomCenter,
            child: Text(text),
          ),
          Align(
            alignment: Alignment.topCenter,
            child: IconButton(
              icon: Icon(Icons.edit),
              onPressed: onPressed,
              tooltip: tooltip,
            ),
          ),
        ],
      ),
    );
  }

@pedez
Copy link
Author

pedez commented Jun 30, 2020

You can use a Stack for this. I use this helper function:

  Widget _buildIconButtonWithText(
    Function onPressed,
    String text,
    String tooltip,
  ) {
    return Container(
      width: 68,
      height: 55,
      child: Stack(
        children: [
          Align(
            alignment: Alignment.bottomCenter,
            child: Text(text),
          ),
          Align(
            alignment: Alignment.topCenter,
            child: IconButton(
              icon: Icon(Icons.edit),
              onPressed: onPressed,
              tooltip: tooltip,
            ),
          ),
        ],
      ),
    );
  }

Thank you so much for this answer! I will close this now as this is a quality solution

@pedez pedez closed this as completed Jun 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants