Какое поведение обеспечивают свойство margin и виджет Padding() в Flutter?

  • 6 августа 2023 г. 7:05
Ответы на вопрос 2
Свойство margin определяет расстояние между виджетом и другими элементами на экране, а виджет Padding() определяет отступы внутри виджета. Они позволяют настроить внешний вид приложения, изменяя расположение и размер элементов на экране.
A child element within a container is first surrounded by padding, which includes any borders that are present in the decoration. Then, additional constraints are applied to the padded area, taking into account the width and height constraints if they are specified. The container itself is then surrounded by empty space described by the margin. You can find more information in the Flutter documentation: [https://api.flutter.dev/flutter/widgets/Container-...]

In CSS, elements can be positioned on different sides of the border, similar to how it works in Flutter. It seems that padding does not collapse with surrounding padding, just like in CSS. However, the documentation does not provide clear information about margin collapsing, so we cannot say for sure if it behaves the same way as in CSS.
Похожие вопросы