2021/11 9

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

Flutter - 앱 종료 하기

Flutter 에서 앱을 종료하는 방법 * iOS 와 AOS 일때의 종료 코드가 다름이 주의 exit(0); or if (Platform.isIOS) { exit(0); } else { SystemNavigator.pop(); } 다만, exit(0) 는 강제종료이기 때문에 Android UI 상으로 앱이 강제종료 느낌이 강하게 들어서 사용하지 않는걸 추천한다. 그리고 iOS 같은 경우도 아이폰에서의 컨셉상 앱을 종료한다라는 개념이 없고 홈버튼에서 쓸어서 혹은 밀어서 끄기 때문에, 해당 종료 함수는 iOS 에서 부적절할 수도 있다. 참고하시길 바란다. 관련 참고 링크 iOS 에서 동작하지 않지만 AOS 에서는 동작 SystemChannels.platform.invokeMethod('SystemNaviga..

Dev/Flutter 2021.11.09

Flutter - PackageInfo

PackageInfo Flutter 에서 앱의 버전 정보를 얻어오기 우해서 PackageInfo 를 얻으려 한다면 Plus Plugins 의 라이브러리를 추가해야한다. pubspec.yaml 에서 필요한 라이브러리만 추가하면 된다. 1. 라이브러리를 디펜던시에 추가한다. dependencies: flutter: sdk: flutter battery_plus: "^2.0.1" connectivity_plus: "^2.0.2" device_info_plus: "^3.1.0" network_info_plus: "^2.0.2" package_info_plus: "^1.3.0" sensors_plus: "^1.2.1" share_plus: "^3.0.4" android_alarm_manager_plus: "^2...

Dev/Flutter 2021.11.09

Mac Path 경로 설정

* 터미널 설정에 따라서 bash_profile or zshrc 에 경로 설정을 해야한다. 필자와 같이 터미널이 zsh 로 기본 으로 되어 있다면 bash_profile 을 할 경우에는 매번 source ~/.bash_profile 처리를 해야하기 때문에 zshrc 로 처리하는게 편할 것이다. bash_profile 과 zshrc 의 차이 설명 링크 1. open (1) bash_profile 열기 (새 창으로 뜬다) open -e ~/.bash_profile or open -e ~/.zshrc (2) bash_profile 에서 경로 추가 export PATH=$PATH:{플러터 폴더 경로}/bin 필자의 경우 export PATH=$PATH:/Users/hoon/flutter/bin (3) 변경된 b..

Dev/Mac모닝 2021.11.03