Application
-
[ Flutter ] Hive ( NoSql ) 추가, 수정, 삭제Application/Flutter 2024. 9. 1. 16:23
Addhive box에 데이터를 추가할 경우 단순하게 add를 통해 데이터를 추가 할 수 있다. 처음엔 기존 index값을 현재 _costBox의 length를 기준으로 해서 했지만수정 삭제 기능이 들어가면서 index값이 계속 꼬여 수정이나 삭제가 다른 데이터에 적용되서 방식을 변경 void add(String title, String pay) { Cost cost = Cost(id: getNextId(_costBox), title: title, pay: pay); _costBox.add(cost); } box가 비어있다면 0을 return하고그 외는 현재 박스의 마지막 값의 id에서 +1 을 해주는 방식으로 index를 설정 int getNextId(Box box) { if (bo..
-
[ Flutter ] Alert DialogApplication/Flutter 2024. 9. 1. 16:09
삭제 기능을 구현하기 위해 alert을 사용AlertDialogalertDialog는 다른 삭제 부분에서 사용 가능성을 고려하여 컴포넌트화 시킴class CustomAlertDialog extends StatelessWidget { const CustomAlertDialog({super.key}); @override Widget build(BuildContext context) { return AlertDialog( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16.0)), backgroundColor: boxColor, title: Text( '정말루?!', style..
-
[ Flutter ] Slidable CustomApplication/Flutter 2024. 8. 29. 00:36
이전에 Hive를 활용하여 저장 기능을 구현하였기에 이제 수정과 삭제 기능을 구현하기 위해서 Slidable을 활용https://pub.dev/packages/flutter_slidable flutter_slidable | Flutter packageA Flutter implementation of slidable list item with directional slide actions that can be dismissed.pub.devSlidable은 리스트를 옆으로 넘겨 삭제 혹은 버튼을 선택할 수 있도록 해준다.DependenciesSlidable을 사용하기 위해 yaml파일에 의존성 추가dependencies: flutter: sdk: flutter # list Slider fl..
-
[ Flutter ] Hive ( NoSql ) 데이터 저장Application/Flutter 2024. 8. 24. 17:11
이전 hive 세팅이 끝났으므로실제 데이터를 추가 기능을 구현 Box Add이전 모달창에서 리스트에 추가하는 방식에서 hive에 데이터 추가 로직을 추가버튼쪽에서는 이전 구현에서 바뀐점 없이 그대로 진행하며 addFixList함수에 로직을 추가Container SaveChildButton(BuildContext context) { final fixSaveProvider = Provider.of(context, listen: false); return Container( margin: const EdgeInsets.fromLTRB(0, 0, 16.0, 0), alignment: Alignment.centerRight, child: ElevatedButton..
-
[ Flutter ] Hive ( NoSql ) SettingApplication/Flutter 2024. 8. 24. 16:58
이전 ture, false값으로 다크모드를 설정할때는 캐시 저장 방식을 사용했지만,데이터를 저장하기 위해서 캐시 저장방식이 불가하여 hive 라이브러리를 사용하여 데이터를 저장하는 방식으로 진행 로컬로 데이터를 저장하기 위해서 다른 DB를 사용하지 않고 hive를 사용Hive Dependenciesdependencies: flutter: sdk: flutter hive: ^2.2.3 hive_flutter: ^1.1.0 dev_dependencies: flutter_test: sdk: flutter uild_runner: ^2.4.7 hive_generator: ^2.0.1 hive를 사용하기위해hive, hive_flutteruild_runner, hive_generator를 추가..
-
[ Flutter ] 금액 formatter 설정Application/Flutter 2024. 7. 20. 18:48
금액을 표시할때 세자리 단위로 , 를 만들기위해 formatter를 만들려고 한다. 이전에 캘린더를 사용할때intl 의존성을 추가했는데 이를 활용하여 formatter를 만들 수 있었다.dependencies: flutter: sdk: flutter intl: ^0.19.0 공용 함수를 만들기 위해서 utils 폴더를 만들어 format 함수를 구현formatMoney함수에서 String 타입으로 변수를 받는다.이를 double형태로 변경하여intl 에 있는 NumberFormat함수를 이용하여 , 를 찍도록 한 후 local을 ko로 설정이후 그 값을 returnimport 'package:intl/intl.dart';String formatMoney(String money) { final ..
-
[ Flutter ] 팝업에서 입력값 리스트에 추가하기Application/Flutter 2024. 7. 20. 18:42
팝업에서 금액을 입력하면 바로 리스트에 추가시키는 기능을 구현View Setting리스트를 관리하기위해 리스트 변수를 선언Cost라는 타입을 만들고 Cost타입의 빈 리스트를 선언class Cost { final int id; final String title; final String pay; Cost({ required this.id, required this.title, required this.pay, });}List fixedCost = []; 이후 ExpansionChild에 리스트로 보여주기 위해서 child: ExpansionTile( backgroundColor: Colors.transparent, title: Text('It..
-
[ Flutter ] TextField 사용 및 StyleApplication/Flutter 2024. 7. 20. 17:18
기존의 TextField를 사용하니 이쁘지가 않아서스타일을 적용하고자 한다. 우선 textField widget을 만들어서 위치를 잡기 위해 Padding을 설정color는 현재 전역으로 만든 textColor를 사용Padding textField() { return Padding( padding: EdgeInsets.all(16.0), child: TextField( style: TextStyle(color: textColor), ), ); }최대한 현재 어플의 스타일과 비슷하게 만들기 위해배경색 및 테두리 작업을 진행textField의 경우 InputDecoration을 활용하여 style을 넣어줄 수 있다.hintText 와 hintStyle을 활..