Repository: bdlukaa/fluent_ui

Issue:
🐛 A child of `Button` has an unbound height constraint.
**Describe the bug**
A child of `Button` has an unbound height constraint.

**To Reproduce**
Steps to reproduce the behavior:
1. run this example
```dart
void main() {
  runApp(FluentApp(
    home: Stack(
      children: [
        ConstrainedBox(
          constraints: BoxConstraints(
              maxHeight: 100, minHeight: 10, minWidth: 10, maxWidth: 100),
          child: LayoutBuilder(builder: (context, constraints) {
            print("outer: $constraints");
            return Button(
              child: LayoutBuilder(
                builder: (context, constraints) {
                  print("inner: $constraints");
                  return Container();
                },
              ),
              onPressed: () {},
            );
          }),
        ),
      ],
    ),
  ));
```
2. Logs:
```
flutter: outer: BoxConstraints(10.0<=w<=100.0, 10.0<=h<=100.0)
flutter: inner: BoxConstraints(0.0<=w<=76.0, 0.0<=h<=Infinity)
```

**Expected behavior**
Centering a child that's to small seems reasonable, but the upper bound should be respected.

**Screenshots**
none

**Additional context**
I think ef3cd8764915b7627d44b6bb7976b164130a4069 broke this.




Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e27a50d72..7cdec4b59 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,7 +1,8 @@
 ## next
 
-* feat: Added `DatePicker.fieldFlex` to control the width proportion of each field.
-* fix: `Slider` thumb is correct rendered when it's on the edges.
+* fix: A child of `Button` has an unbound height constraint. ([#1039](https://github.com/bdlukaa/fluent_ui/issues/1039))
+* feat: Added `DatePicker.fieldFlex` to control the width proportion of each field. ([#1053](https://github.com/bdlukaa/fluent_ui/pull/1053))
+* fix: `Slider` thumb is correct rendered when it's on the edges. ([#1046](https://github.com/bdlukaa/fluent_ui/pull/1046)
 * feat: Added `TabView.addIconBuilder` ([#1047](https://github.com/bdlukaa/fluent_ui/pull/1047))
 
 ## 4.8.6
diff --git a/lib/src/controls/inputs/buttons/base.dart b/lib/src/controls/inputs/buttons/base.dart
index 04cd9cc2f..bb0a98262 100644
--- a/lib/src/controls/inputs/buttons/base.dart
+++ b/lib/src/controls/inputs/buttons/base.dart
@@ -214,10 +214,10 @@ class _BaseButtonState extends State<BaseButton> {
                     ),
                 textAlign: TextAlign.center,
                 // used to align the child without expanding the button
-                child: Column(
-                  mainAxisSize: MainAxisSize.min,
-                  mainAxisAlignment: MainAxisAlignment.center,
-                  children: [widget.child],
+                child: Center(
+                  heightFactor: 1,
+                  widthFactor: 1,
+                  child: widget.child,
                 ),
               ),
             ),


Test patch:
diff --git a/test/button_test.dart b/test/button_test.dart
new file mode 100644
index 000000000..918ae11e0
--- /dev/null
+++ b/test/button_test.dart
@@ -0,0 +1,49 @@
+import 'package:fluent_ui/fluent_ui.dart';
+import 'package:flutter_test/flutter_test.dart';
+
+void main() {
+  testWidgets(
+    'Test constraints',
+    (WidgetTester tester) async {
+      await tester.pumpWidget(Directionality(
+        textDirection: TextDirection.ltr,
+        child: FluentTheme(
+          data: FluentThemeData(),
+          child: Center(
+            child: ConstrainedBox(
+              constraints: const BoxConstraints(
+                minWidth: 10,
+                maxWidth: 100,
+                minHeight: 20,
+                maxHeight: 200,
+              ),
+              child: Button(
+                child: const SizedBox.shrink(),
+                onPressed: () {},
+              ),
+            ),
+          ),
+        ),
+      ));
+
+      var buttonBox = tester.firstRenderObject<RenderBox>(find.byType(Button));
+      var innerBox = tester.firstRenderObject<RenderBox>(find.byType(SizedBox));
+
+      expect(
+          buttonBox.constraints,
+          const BoxConstraints(
+            minWidth: 10,
+            maxWidth: 100,
+            minHeight: 20,
+            maxHeight: 200,
+          ));
+      expect(buttonBox.size.width, greaterThanOrEqualTo(10));
+      expect(buttonBox.size.height, greaterThanOrEqualTo(20));
+
+      expect(innerBox.constraints.smallest, Size.zero);
+      expect(innerBox.constraints.maxWidth, lessThanOrEqualTo(100));
+      expect(innerBox.constraints.maxHeight, lessThanOrEqualTo(200));
+      expect(innerBox.size, Size.zero);
+    },
+  );
+}