목록flutter android (2)
Foggy day

이번 포스팅에서는 EventChannel에 대해 알아보겠습니다. EventChannel(이벤트채널)이란? - 이벤트 채널은 플랫폼들이 이벤트 스트림을 사용해서 통신하는 방법입니다. 데이터 전송 방향은 Native -> Flutter입니다. 1. Dart EventChannel 2. Android EventChannel 1. Dart EventChannel 먼저 Dart 코드에서 이벤트 채널(스트림)을 등록해 보겠습니다. EventChannel 클래스를 생성해야 하는데 이때 생성자에 채널명을 넣어주세요. EventChannel 클래스의 receiveBroadcastStream 함수의 리턴 타입은 Stream이므로 listen 함수를 구현할 수 있습니다. listen 함수의 event에는 Native에서 전..

이번 포스팅에서는 MethodChannel에 대해 간략히 살펴보고, Android Native와 통신하는 방법을 알아보겠습니다. Flutter는 MethodChannel을 사용해서 각 플랫폼과 통신할 수 있습니다. 메소드 채널은 비동기방식이며 FIFO 순서를 보장합니다. 1. Flutter -> Android Native 2. Android Native -> Flutter 1. Flutter -> Android Native 먼저 볼 것은 Flutter에서 Android Native의 함수를 호출하는 방법입니다. - Flutter(Dart) Flutter 측면에서 호출하는 방식은 간단합니다. MethodChannel 클래스를 생성하고, 생성자에 채널 이름으로 원하는 문자열을 넣습니다. 그리고 invokeM..