1. appbar 추가 및 바텀모달추가
- expenses.dart
void _openAddExpenseOverlay() {
showModalBottomSheet(
context: context, builder: (ctx) => const NewExpense());
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Flutter ExpenseTracker"),
actions: [
IconButton(
onPressed: _openAddExpenseOverlay, icon: const Icon(Icons.add))
],
),
1) appBar를 통해 상단에 앱바 추가 및 actions를 사용하여 아이콘 주가 및 바텀모달을 연동
- new_expense.dart
import 'package:flutter/material.dart';
class NewExpense extends StatefulWidget {
const NewExpense({super.key});
@override
State<NewExpense> createState() => _NewExpenseState();
}
class _NewExpenseState extends State<NewExpense> {
@override
Widget build(BuildContext context) {
return const Padding(
padding: EdgeInsets.all(16),
child: Column(
children: [
TextField(
maxLength: 50,
decoration: InputDecoration(label: Text("Title")),
),
],
),
);
}
}
1) 바텀 모달 위젯
2) TextField를 통해 값 입력 가능
- 결과 화면
'코딩강의 > expense_tracker(플러터-유데미)' 카테고리의 다른 글
~119. Creating a Fullscreen Modal (0) | 2023.09.02 |
---|---|
115. Adding a Dropdown Button (0) | 2023.08.31 |
~114. Working with "Futures" for Handling Data from the Future (0) | 2023.08.29 |
~111. Exercise Solution (0) | 2023.08.29 |
~104. Using Icons & Formatting Dates (0) | 2023.08.27 |