CodeBlanks Logo Icon CodeBlanks

Summary - Platform plugin

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 -> handle

Practice Print the three sides

In main, with three separate print calls, print 'Dart', 'Android', 'iOS' in order.

Starter code

main.dart
void main() {
  // 'Dart', 'Android', 'iOS' üç ayrı print ile yazdır
}

Sample solution

main.dart
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

Question
MyPlugin.____();
Answer
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

All lessons in Expert