flutter 기본

Gong Kang·2022년 8월 2일
0

flutter

목록 보기
1/5

flutter 기본 레이아웃 배치

void main 함수를 이용해 runApp 함수를 호출한다

가장 큰 홈화면은 stateless 위젯으로 만들고 MaterialApp
으로 감싼다

그리고 안에 위젯은 Scaffold 위젯으로 감싼다

import 'dart:io';

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'test App',
      theme: ThemeData(
        primaryColor: Colors.blue
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("Scan Library"),
      ),
      body: Padding(
        padding: const EdgeInsets.fromLTRB(30, 40, 0, 0),
        child: Column(
          //mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            const SizedBox(
              height: 20,
            ),
            const Text('hi'),
            const Text('hi2',
              style: TextStyle(
                color: Colors.blue,
                fontSize: 20
              ),
            ),
            const Text('hi3',
              style: TextStyle(
                color: Colors.yellow,
                fontSize: 25
              ),
            ),
            Row(
              children: const [
                Text('kanggongp'),
                SizedBox(
                  width: 10,
                ),
                Text('Hi',
                  style: TextStyle(
                    fontSize: 20,
                    letterSpacing: 1
                  ),
                )
              ],
            )
          ],
        ),
      ),
    );
  }
}




profile
꾸준히 하루에 한번씩..!

0개의 댓글