HIT해
[Flutter] int를 출력하는 방법 본문
728x90
Flutter에서는 int 변수를 문자열로 인식한다
class _HelloPageState extends State<HelloPage> {
String _message = '안녕 world'; // _ 붙이면 private
int _counter = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
floatingActionButton: FloatingActionButton(
child: Icon(Icons.add),
onPressed:
() => _changeMessage()),
appBar: AppBar(title: Text(widget.title),),
body: Center(child: Column(
children: <Widget>[
Text(_message , style: TextStyle(fontSize: 30)),
Text('$_counter' , style: TextStyle(fontSize: 30))
],
)));
_counter 라는 변수를 ' ' 작은 따음표로 묶고 $표기로 변수값을 출력할 수 있다.
'Flutter > Flutter 개발 노트' 카테고리의 다른 글
[Flutter] 화면 겹치기 Stack 사용해보기 (0) | 2024.01.30 |
---|---|
[Flutter] TextButton 사용해보기 (0) | 2024.01.30 |
[Flutter] Failed assertion: line 1972 pos 12: 'hasSize' (0) | 2024.01.30 |
[Flutter] 변수 private, public (0) | 2024.01.13 |
[Flutter] 상태를 변경하는 방법 (0) | 2024.01.13 |