Flutter/Flutter 개발 노트
[Flutter] int를 출력하는 방법
힛해
2024. 1. 13. 15:40
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 라는 변수를 ' ' 작은 따음표로 묶고 $표기로 변수값을 출력할 수 있다.