Mobile Develop/Flutter
[Flutter] Hello World 정적 페이지 소스
nyangzzi
2022. 3. 16. 16:52
반응형
텍스트만 출력하면 되는 정적인 화면을 가지므로 StatelessWidget을 사용한다.
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: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(),
);
}
}
//정적 화면 디자인
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context){
return Scaffold(
appBar: AppBar(
title: Text('Hello World'),
),
body: Text(
'Hello World',
style: TextStyle(fontSize: 40),
),
);
}
}
[실행 결과]
반응형