This project demonstrates how to use Flutter MethodChannels to communicate between Flutter (Dart) and native Android (Kotlin).
It includes simple examples for sending messages and retrieving device information like battery level and device model directly from Android.
- Get a message from Android using a platform channel
- Fetch device info (battery level & model) via Kotlin
- Display data in Flutter UI with responsive updates
- Error handling with SnackBars for user feedback
| Layer | Technology |
|---|---|
| Frontend | Flutter (Dart) |
| Backend / Native | Android (Kotlin) |
| Channel Type | MethodChannel |
- Flutter calls a MethodChannel with a method name (
getMessageorgetDeviceInfo). - Android’s
MainActivity.ktlistens for these calls and executes corresponding native code. - The result (string or map) is sent back to Flutter and displayed in the UI.
| Method | Description | Returns |
|---|---|---|
getMessage |
Sends a text message from Android | String |
getDeviceInfo |
Returns device info & battery level | Map<String, dynamic> |