-
카테고리
-
세부 분야
모바일 앱 개발
-
해결 여부
해결됨
상태 변경 하기 <-여기서 막히는거 질문입니다.
20.06.07 21:58 작성 조회수 145
0
안녕하세요 동영상 현재 상태 변경 하기 보고 있습니다.
나름 똑같아 하고 동그란 버튼 눌러도 Hello World가 헬로 월드로 안바뀌네요
ㅜ 확인 부탁드립니다.
답변을 작성해보세요.
0
0
오준석
지식공유자2020.06.08
아래 코드 그대로 복사 붙여넣기 해서 해 보세요.
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
답변 4