Flutter 54

Flutter - Json 데이터 사용하는 방법

Flutter 에서 Json 데이터를 파싱해서 사용하기 위해서는 파싱할 수 있도록 설정 작업을 해야한다. 1. pubspec.yaml 에 라이브러리를 추가한다. 라이브러리 추가 방버 : 링크 참조 dependencies: # Your other regular dependencies here json_annotation: dev_dependencies: # Your other dev_dependencies here build_runner: json_serializable: json_serializable 링크 2. Json 을 받을 수 있는 Object 클래스를 만든다. @JsonSerializable() class User { User(this.name, this.email); String name; S..

Dev/Flutter 2022.01.11

Flutter - Calendar / SfCalendar / Syncfusion / 캘린더

Flutter 에도 많은 라이브러리들이 존재한다. 그리고 잘 만들어져 있고 커스텀하기 좋은 Calendar 라이브러리가 Syncfusion 에서 만든 Calendar 입니다. - Syncfusion Flutter Calendar 라이브러리 링크 ✔️ 데이터 리로딩 이슈 SfCalendar 를 사용할때, 데이터를 셋팅해주는 부분이 있다. 그런데 여기서 나는 API 에서 데이터를 다시 받아와서 캘린더에 뿌려줘야하는데 종종 데이터를 제대로 뿌려주지 못하는 이슈가 발생했는데, API 에서는 데이터를 잘 내려받지만 캘린더에 표시가 됐다가 안됐다가를 반복해서 이래저래 시도해보다가 검색해서 데이터를 다시 리로딩하는 방법을 찾고 수정했습니다. - 리로딩 이슈 해결 방법 링크 ❗ 처음 시도한 방식 1. 아래와 같이 UI..

Dev/Flutter 2022.01.07

Flutter - Divider(구분선)

Flutter 에서 구분선을 구현하는 방법 1. 기본적인 가로 구분선 구현 Divider(thickness: 1, height: 1, color: myColor) Divider.dart 생성자 const Divider({ Key? key, this.height, this.thickness, this.indent, this.endIndent, this.color, }) 2. 세로 구분선 VerticalDivider(thickness: 1, width: 1, color: color) VerticalDivider.dart 생성자 const VerticalDivider({ Key? key, this.width, this.thickness, this.indent, this.endIndent, this.color,..

Dev/Flutter 2021.12.29

Flutter - TextButton 기본 레이아웃 스타일 없애는 방법 2가지

1. Style 로 없애는 방법 TextButton( onPressed: (){}, child: Text('버튼'), style: TextButton.styleFrom( minimumSize: Size.zero, padding: EdgeInsets.zero, tapTargetSize: MaterialTapTargetSize.shrinkWrap, ), ) https://stackoverflow.com/a/69382707/3897810 2. InkWell 로 감싸는 방법 InkWell( onTap: () { // Text 클릭시 반응하는 곳 }, child: const Padding( padding: EdgeInsets.all(5.0), child: Text('버튼'), ), ),

Dev/Flutter 2021.12.16

Flutter - 함수 파라미터에 기본 인자 설정하기

Flutter 함수에 기본 인자값이 들어가는 파라미터 설정하는 방법 Kotlin 1. 기본 인자 설저하는 방법 fun bottomSimpleButton(title: String, name: String = "후니") 2. 해당 함수를 다음과 같이 호출하면 된다. // Title 만 입력하고 Name 은 기본값 사용. bottomSimpleButton("Title") // Title 과 Name 모두 입력. bottomSimpleButton("Title", "Name") bottomSimpleButton(title = "Title", name = "Name") bottomSimpleButton(name = "Name", title = "Title") Flutter 1. 함수에 아래와 같이 기본 인자 부분을..

Dev/Flutter 2021.11.23

Flutter - listener, callback 구현하기

Flutter 에서 Custom callback 함수를 간단하게 구현하는 방법 1. 인터페이스 역할을 해주는 함수를 typedef 로 정의 typedef DateTimeCallback = void Function(DateTime); 2. 원하는 콜백을 만들고 싶은 함수에 DateTimeCallback 이라 선언한 함수를 파라미터로 넣어준다. class SelectCalendar { Future showPickerDate(BuildContext context, DateTime initDate, DateTimeCallback callback) async { await showDatePicker( .... }).then((value) => { if (value != null) { callback(value) ..

Dev/Flutter 2021.11.19

Flutter - Syncfusion Calendar 사용

Syncfusion Flutter 캘린더 라이브 사용 방법 라이브러리 참고 1. 라이브러리 추가 syncfusion_flutter_calendar: ^19.3.48 2. SfCalendar 추가 @override Widget build(BuildContext context) { return Scaffold( body: Container( height: 500, width: double.infinity, child: Column( children: [ ... _SfCalendarSetting() ... ], ), ), ); } Widget _SfCalendarSetting() { return SfCalendar( view: CalendarView.month, ... headerHeight: 0, ... )..

Dev/Flutter 2021.11.10