Skip to content

A simple Flutter app demonstrating platform channel communication between Flutter and native Android using Kotlin to fetch battery level and device information.

Notifications You must be signed in to change notification settings

arminmehraeen/Flutter-Channel

Repository files navigation

🔌 Flutter ↔ Android Platform Channel Example

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.


🚀 Features

  • 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

🛠️ Tech Stack

Layer Technology
Frontend Flutter (Dart)
Backend / Native Android (Kotlin)
Channel Type MethodChannel

📱 How It Works

  1. Flutter calls a MethodChannel with a method name (getMessage or getDeviceInfo).
  2. Android’s MainActivity.kt listens for these calls and executes corresponding native code.
  3. The result (string or map) is sent back to Flutter and displayed in the UI.

🧩 Example Methods

Method Description Returns
getMessage Sends a text message from Android String
getDeviceInfo Returns device info & battery level Map<String, dynamic>

About

A simple Flutter app demonstrating platform channel communication between Flutter and native Android using Kotlin to fetch battery level and device information.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published