본문 바로가기
안드로이드 개발/📚 Compose 공부

Flutter VS Compose - 01

by 아이엔 / ienground 2024. 8. 10.

Padding

Compose

modifier = Modifier
    .padding(16.dp)

Flutter

Padding(
    padding: const EdgeInsets.{...},
    child: ...
)

conditional widget

Compose

if (...) A else B

Flutter

if (...) ... [
    A
] else ... [
    B
]

weight

Compose

Column {
    Text(
        modifier = Modifier.weight(0.2f)
    )
    Text(
        modifier = Modifier.weight(0.8f)
    )
}

Flutter

Column(
    children: [
        Expanded(
            flex: 2,
            child: ~
        ),
        Expanded(
            flex: 8,
            child: ~
        )
    ]
)

width, height:

Compose

Column {
    Text(
        modifier = Modifier.width(200.dp).height(100.dp)
    )
}
  • maxWidth: fillMaxWidth

Flutter

Column(
    children: [
        SizedBox(
            width: 200,
            height: 100
            child: ~
        )
    ]
)
  • maxWidth: double.maxFinite