#4 첫 화면 구현(1)

Gino·2023년 6월 13일
1

코딩셰프 flutter

목록 보기
4/9

  • StatelessWidget 으로 AppBar 와 Body 기초 구성
import 'package:flutter/material.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: 'Character card',
      home: MyCard(),
    );
  }
}

class MyCard extends StatelessWidget {
  const MyCard({super.key});

  
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        // 상단 앱바
        title: const Text('Rank'),
        centerTitle: true,
        backgroundColor: Colors.red[400],
        elevation: 5.0, // 앱바 그림자 설정
      ),
      body: const Center(
        // 가로축 정중앙 위치
        // Center, Padding 위젯 등으로 위치 잡아주고 컬럼 생성
        child: Column(
          // 세로축 정렬
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text('Hello'),
            Text('Hello'),
            Text('Hello'),
          ],
        ),
      ),
    );
  }
}
profile
나무를 심는 사람

0개의 댓글