플러터 위젯 가로세로 배치

고동이의 IT·2025년 9월 4일
0

flutter

목록 보기
3/5

가로배치

import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp()); /* 앱 구동 시켜주세요 MyApp()에 메인메이지 넣어주면됨 */
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});
  @override
  Widget build(BuildContext context) {

    /* 실제 내용은 여기 안에 */
    return MaterialApp(
      /* 여러가지 위젯 가로로 배치 -  Row, children 이용 */
      home: Scaffold(
        body: Row(
          children: [
            Icon(Icons.star),
            Icon(Icons.star),
            Icon(Icons.star),
            
          ],
        ),
      )
    );

  }
}

세로배치

import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp()); /* 앱 구동 시켜주세요 MyApp()에 메인메이지 넣어주면됨 */
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});
  @override
  Widget build(BuildContext context) {

    /* 실제 내용은 여기 안에 */
    return MaterialApp(
      /* 여러가지 위젯 세로로 배치 -  Column, children 이용 */
      home: Scaffold(
        body: Column(
          children: [
            Icon(Icons.star),
            Icon(Icons.star),
            Icon(Icons.star),

          ],
        ),
      )
    );

  }
}
profile
삐약..뺙뺙

0개의 댓글