Problem Statement
Explain the differences between Padding, Margin, Center, and Align widgets and when to use each.
Explanation
Padding widget adds empty space inside a widget, between the widget's boundary and its child. It takes EdgeInsets parameter specifying padding amount: EdgeInsets.all for uniform padding, EdgeInsets.symmetric for horizontal/vertical, or EdgeInsets.only for specific sides. Padding increases the widget's total size by the padding amount and is commonly used to create breathing room around content.
Margin is not a separate widget but a property of Container. It adds space outside the widget, between the widget and its neighbors or parent. The difference is subtle: padding is inside the widget's decoration (background, border), while margin is outside. If you only need margin without Container's other features, use Padding widget on the parent instead for better performance.
Center widget centers its child within available space, both horizontally and vertically. It's equivalent to Align with alignment: Alignment.center but more explicit and readable. Center expands to fill available space, then positions its child at the center. Use Center when you want simple centering without additional alignment options.
Align widget positions its child within itself using Alignment values ranging from -1 to 1 on x and y axes. Alignment.topLeft is (-1, -1), Alignment.center is (0, 0), Alignment.bottomRight is (1, 1). Align gives precise control over positioning and is more powerful than Center. Use FractionalOffset for percentage-based positioning (0.0 to 1.0 range instead of -1 to 1).
