본문 바로가기

전체 글141

[Flutter] Setting the height of the AppBar MOTIVATION Appbar를 없애면 StatusBar를 설정해야하는데 단순하게 Appbar의 높이를 낮춰서 없는 것처럼 렌더링하고 싶을때 class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Example', home: Scaffold( appBar: PreferredSize( preferredSize: Size.fromHeight(50.0), // here the desired height child: AppBar( // ... ) ), body: // ... ) ); } } REFERENCE https://stackoverflow.com/questi.. 2023. 2. 1.
[Flutter] How to go back and request API to refresh the previous page : 이전페이지 이동 후 API 호출 Context FirstPage에서 조회되는 내용을 편집을 하려고 SecondPage로 Route. SecondPage에서 원하는 내용으로 편집하고 서버 DB에 데이터 Post, 편집 완료 버튼을 누르면 FirstPage로 이동 FirstPage에서는 편집된 내용이 조회 Implement FirstPage의 Route하는 위젯에서 SecondPage의 처리결과를 받아서 정상일때 API를 호출 FirstPage // FirstPage의 편집 버튼 TextButton( onPressed: () async { // SecondPage에서 다시 돌아올때 결과를 result 변수에 받기. 이때, await로 받아 올때까지 기다렸다가 처리 final result = await Get.toNamed('/editFar.. 2023. 1. 31.
[Flutter] Connecting flutter simulator to localhost api 아직 개발중인 백엔드(Docker container로 띄움) api로 테스트할때 시뮬레이터가 접속을 하려면 http://서버IP주소:PORT 형태로 링크를 사용하면 됨 참고 https://medium.com/@podcoder/connecting-flutter-application-to-localhost-a1022df63130 Connecting Flutter application to Localhost Connecting your flutter application is not an easy task, as it seems to be. Especially when you want to run your Flutter application… medium.com 2023. 1. 27.
[Flutter] flutter DateTime parse formatting API는 서버의 DB에 저장된 정보를 그대로 전달하는것이 기본이고 날짜의 경우, DateTime fomat이 백엔드 설정에 따라 여러가지 경우가 발생할 것이다. 클라이언트는 이러한 상황에 대처해야하는데 이럴때 사용하는데 DateFormat과 DateTime.parse이다. 예를 들어 API가 전달해주는 날짜 정보는 다음과 같다. 그러나 내가 클라이언트에서 표현하고 싶은 형태는 "2023-02-27 13:27:00" 이다. 그럴때는 아래와 같이 DateTime.parse로 날짜 형식을 DateTime으로 가져온 뒤, DateFormat으로 원하는 형태를 맞춰주면 된다. 여기서는 intl 패키지를 사용할 것이다. import 'package:intl/intl.dart'; Text( DateFormat("yy.. 2023. 1. 27.
[Flutter] List copy 새로운 리스트를 생성하여 복사할때 List.from()을 이용 기존에 있는 리스트에 복사할때 addAll() 이용 참고 https://codechacha.com/ko/dart-clone-list/ Flutter/Dart - 리스트 복사 방법 리스트 복사, 리스트의 요소들을 다른 리스트에 추가하는 방법을 소개합니다. List.from(list)는 리스트를 생성할 때 list의 모든 요소를 초기 값으로 추가합니다. 아래와 같이 list와 동일 요소를 갖 codechacha.com 2023. 1. 17.
[Flutter] flutter textfield height textField에 textController를 사용하여 서버 데이터를 넣어줄때 textField의 높이가 자동으로 커지지 않는 문제가 있었다. 그 때는 maxLines, minLines를 지정해주면 된다. TextField( controller: farmWorkDetailTextController, onEditingComplete: () { FocusScope.of(context).unfocus(); }, maxLines: 10, minLines: 1, decoration: const InputDecoration( border: OutlineInputBorder(), contentPadding: EdgeInsets.all(8.0), hintText: '자세히 기록하고싶은 사항을 입력해보세요'), ), .. 2023. 1. 17.
[Flutter] 함수형프로그래밍 List of Maps VS Map of Maps 데이터 접근 상황 : 달력에 입력된 데이터를 넣어야함 API response가 다음과 같은 List of Map 형태일때 List farmWorkData = [ { "date": "2023-01-16", "work_list": ["방제", "적엽", "정식"], "work_detail": "1구역 비닐 멀칭\n1구역 방제\n컨설턴트 방문하여 급액처방 EC 양분조절\n2구역 정식", "work_image_list": [ { "image_url": "https://ichef.bbci.co.uk/news/976/cpsprodpb/10928/production/_111408876__96579830_aseveralfruitpickersbendingoverbbc.jpg.webp", "mesure_dt": "2022-12-24 .. 2023. 1. 16.
[Flutter] ReorderableListView 순서를 변경할 수 있는 ListView를 사용하고 싶을때 Widget editFarmWorkListWidget() { return Expanded( child: ReorderableListView.builder( itemCount: userWorkList.length, itemBuilder: (context, index) { return Padding( key: ValueKey(userWorkList[index]), //키를 필요로함 padding: const EdgeInsets.symmetric(vertical: 12.0), child: editFarmWorkUnitWidget(_farmWorkTextControllerList[index]), ); }, // 순서를 바꿔주는 함수 onReorder: (.. 2023. 1. 13.
[Flutter] flutter text overflow in container 컨테이너 안에 글자가 너무 많을때 처리방법 Container( child: Center( child: Text( "엄청엄청 긴 글", overflow: TextOverflow.ellipsis, ), ), https://stackoverflow.com/questions/44579918/flutter-wrap-text-on-overflow-like-insert-ellipsis-or-fade Flutter - Wrap text on overflow, like insert ellipsis or fade I'm trying to create a line in which center text has a maximum size, and if the text content is too large, it fits in .. 2023. 1. 12.