반응형
- 코드 작성
import 'dart:async';
import 'package:flutter/material.dart';
class ToDoListPage extends StatefulWidget {
const ToDoListPage({Key? key}) : super(key: key);
@override
State<ToDoListPage> createState() => _ToDoListPageState();
}
class _ToDoListPageState extends State<ToDoListPage> {
final _todoController = TextEditingController();
List<String> _todoList = [];
void _addTodo() {
setState(() {
_todoList.add(_todoController.text);
_todoController.text = '';
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('To-Do List'),
),
body: Column(
children: <Widget>[
Container(
padding: EdgeInsets.all(10),
child: TextField(
controller: _todoController,
decoration: InputDecoration(
hintText: 'Enter a to-do',
),
),
),
ElevatedButton(
child: Text('Add'),
onPressed: _addTodo,
),
Expanded(
child: ListView.builder(
itemCount: _todoList.length,
itemBuilder: (context, index) {
return ListTile(
title: Text(_todoList[index]),
);
},
),
),
],
),
);
}
}
반응형
'개발 > Flutter' 카테고리의 다른 글
Flutter 플러터 Progress bar 진행바 간단 구현 LinearProgressIndicator (0) | 2023.03.09 |
---|---|
플러터 Flutter For문 Switch문 간단 구현 (0) | 2023.02.18 |
플러터 Flutter if else문 간단 구현법 (0) | 2023.02.18 |
플러터 Flutter 메모장 구현하기 Notepad (0) | 2023.01.29 |
Flutter 플러터 타이머 간단 구현 Timer (0) | 2023.01.29 |
Flutter 플러터 URL 주소 열기 간단 구현 url launcher (0) | 2022.12.25 |
Flutter 플러터 화면 전환 애니메이션 삭제 간단 사용법 Navigator Animation (0) | 2022.12.25 |
Flutter 플러터 백 버튼 무시하기 WillPopScope (0) | 2022.12.25 |
댓글