Widget Tree
Widget들의 부모, 자식 관계
MainAxisAlignment
import 'package:flutter/material.dart';
class HomeScreen extends StatelessWidget {
const HomeScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
bottom: false,
child: Container(
color: Colors.black,
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Container(
color: Colors.red,
width: 50.0,
height: 50.0,
),
Container(
color: Colors.orange,
width: 50.0,
height: 50.0,
),
],
),
),
),
);
}
}
MainAxisAlignment: 주축 정렬
// start: 시작 -> 기본 값
// end: 끝
// center: 가운데
// spaceBetween: 위젯과 위젯 사이 동일하게 배치
// spaceEvenly: 위젯 사이 동일하게 배치, 끝과 끝에도 빈 간격으로 시작
// spaceAround: spaceEvenly + 끝과 끝 간격은 1/2
CrossAxisAlignment
import 'package:flutter/material.dart';
class HomeScreen extends StatelessWidget {
const HomeScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
bottom: false,
child: Container(
color: Colors.black,
width: MediaQuery.of(context).size.height,
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
// CrossAxisAlignment: 반대축 정렬
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
color: Colors.red,
width: 50.0,
height: 50.0,
),
Container(
color: Colors.orange,
width: 50.0,
height: 50.0,
),
],
),
),
),
);
}
}
// start: 시작
// end: 끝
// center: 가운데 -> 기본 값
// strech: 최대한으로 늘림
'CS > Flutter | Dart' 카테고리의 다른 글
Row, Column 실습 (0) | 2023.07.17 |
---|---|
mainAxisSize, Expanded, Flexible (0) | 2023.07.17 |
Flutter Hello World,,,! (0) | 2023.07.16 |
Dart 3.0 업데이트 주요 내용 - Record, Destructuring, pattern matching, mixin class (0) | 2023.07.13 |
Dart Asynchronous Programming - Stream, yield (0) | 2023.07.12 |