Advanced
Flutter
Q94 / 100
How do you write a Flutter plugin that communicates with native platform code?
Correct! Well done.
Incorrect.
The correct answer is B) Define a MethodChannel in Dart, implement MethodCallHandler in native Android (Kotlin) and iOS (Swift) code, and use invokeMethod() to call native functions
B
Correct Answer
Define a MethodChannel in Dart, implement MethodCallHandler in native Android (Kotlin) and iOS (Swift) code, and use invokeMethod() to call native functions
Explanation
A Flutter plugin uses MethodChannel with a unique channel name. In Dart, call channel.invokeMethod('methodName'). On Android, implement FlutterPlugin and MethodCallHandler in Kotlin. On iOS, implement FlutterPlugin in Swift. The channel name must match exactly.
Progress
94/100