5. 플로터 구조

2022. 7. 7. 14:56플러터(Flutter)

lib/main.dart 에서 구현

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: 'studyFlutter',
      theme: ThemeData(
        primarySwatch: 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('myApp'),
      ),
      body: Center(
        child: Column(
          children: const [
            Text('hi'),
            Text('hi2'),
          ],
        ),
      ),
    );
  }
}