해결된 질문
작성
·
233
답변 4
0
0
아래 코드 그대로 복사 붙여넣기 해서 해 보세요.
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(),
home: HelloPage('Hello World'));
}
}
class HelloPage extends StatefulWidget {
final String title;
HelloPage(this.title);
@override
_HelloPageState createState() => _HelloPageState();
}
class _HelloPageState extends State<HelloPage> {
String _message = 'Hello World';
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Text(
_message,
style: TextStyle(fontSize: 30),
),
floatingActionButton: FloatingActionButton(
onPressed: _changeMessage,
child: Icon(Icons.add),
),
);
}
void _changeMessage() {
setState(() {
_message = '헬로 월드';
});
}
}
0
0