본문 바로가기

Flutter62

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. 함수에 아래와 같이 기본 인자 부분을.. 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) .. 2021. 11. 19.
Flutter - ScrollListView Flutter 에서 ScrollListView 적용 방법 참고 : https://api.flutter.dev/flutter/widgets/SingleChildScrollView-class.html import 'package:flutter/material.dart'; void main() => runApp(const MyApp()); /// This is the main application widget. class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); static const String _title = 'Title'; @override Widget build(BuildContext context) { ret.. 2021. 11. 17.
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, ... ).. 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.. 2021. 11. 9.
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... 2021. 11. 9.