Summary - Platform plugin
- Flutter course
- Expert
- Lesson 20/39
- 4 min
Combine registration, Android and iOS to make a small plugin.
Summary - Platform plugin
A complete plugin brings three pieces together: registration on the Dart side via registerWith, a bridge via MethodChannel, and replies via onMethodCall on Android and handle on iOS. All sides use the same channel name.
// Dart
MyPlugin.registerWith();
// Android
"my_plugin" channel -> onMethodCall
// iOS
"my_plugin" channel -> handlePractice Print the three sides
In main, with three separate print calls, print 'Dart', 'Android', 'iOS' in order.
Starter code
void main() {
// 'Dart', 'Android', 'iOS' üç ayrı print ile yazdır
}Sample solution
void main() {
print('Dart');
print('Android');
print('iOS');
}Expected output
Dart Android iOS
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 How many sides does a complete plugin contain code on?
- 2 (Dart and native)
- Unlimited
- 3 (Dart, Android, iOS) Correct answer
- 1 (Dart only)
Explanation: A complete plugin contains code on three sides: Dart, Android (Kotlin) and iOS (Swift); each side shares the same MethodChannel name.
2 registerWith call
MyPlugin.____();
MyPlugin.registerWith();
Explanation: MyPlugin.registerWith() registers the plugin; invokeMethod calls native, init and setup are for lifecycle or setup but not for registration.
3 Plugin summary matches
| Term | Meaning |
|---|---|
registerWith |
Registration |
Android |
Kotlin side |
iOS |
Swift side |
FlutterPlugin |
Plugin interface |