This repository contains examples of how to use MethodChannel in Flutter to communicate between the Flutter part and native code (Android in this case).
- Create a MethodChannel named "platform_version".
- Invoke the native method to obtain the platform version.
- Display the result in an AlertDialog.
- Create a MethodChannel named "data_channel".
- Define a method in native code to receive a string from Flutter and return it concatenated with "- Native".
- From Flutter, send the string "Hello Flutter" to native code through the channel.
- Display the response on the user interface.
- Implement a bidirectional MethodChannel named "bidirectional_channel".
- Define two methods in native code: flutterToNative and nativeToFlutter.
- From Flutter, invoke the flutterToNative method and send a string.
- From native code, invoke the nativeToFlutter method and send a different string.
- Display both strings on the user interface.
To run unit tests that verify the MethodChannel functionality, follow these steps:
- Open a terminal in the project's root directory.
- Execute the following command:
flutter test
Home | Bidirectional | Platform Version |
---|---|---|
๐ค Rogelio Torres