title: How to vertically or horizontally center a Widget in a Stack?
body: <p>The <code>Center</code> widget centers a widget horizontally and vertically in the center of a Stack. How can one center a widget ONLY horizontally or vertically?</p>
  <p>Centering a widget in a Stack is possible with a Row or Column widget. Can it be done without using those widgets?</p>
  <p>Conditions:</p>
  <ul>
  <li>Cannot use Row / Column.</li>
  <li>The size of the Stack is not known before layout (cannot use hardcoded Positioned values).</li>
  </ul>
  <p>Center widget:</p>
  <p><a href="https://i.stack.imgur.com/sbpmNb.png" rel="noreferrer"><img src="https://i.stack.imgur.com/sbpmNb.png" alt="Centered Widget in Stack" /></a></p>
  <pre><code>Container(
        decoration:
            BoxDecoration(border: Border.all(color: Colors.black87, width: 10)),
        child: Stack(
          children: [
            Center(
              child: Container(color: Colors.amber, width: 50, height: 50),
            ),
          ],
        ),
      );
  </code></pre>
  <p>Center horizontally w/Row:</p>
  <p><a href="https://i.stack.imgur.com/TFTs6b.png" rel="noreferrer"><img src="https://i.stack.imgur.com/TFTs6b.png" alt="Horizontally centered widget in Stack" /></a></p>
  <p><code>Row(mainAxisAlignment: MainAxisAlignment.center)</code></p>
  <p>Center vertically w/Column:</p>
  <p><a href="https://i.stack.imgur.com/RgsrEb.png" rel="noreferrer"><img src="https://i.stack.imgur.com/RgsrEb.png" alt="Vertically centered Widget in Stack" /></a></p>
  <p><code>Column(mainAxisAlignment: MainAxisAlignment.center)</code></p>
  <p>The alignment above is the desired result. Can those results be achieved with other Flutter widgets?</p>