bluetoothadapter: Bluetooth Based Client-Server Apps

Facilitating Bluetooth server sockets for Flutter apps using bluetoothadapter plugin.

Author

Aditya Soni
Aditya SoniSoftware Engineer

Date

Sep 16, 2020

The Problem

We came across a scenario where we were to communicate with a Raspberry Pi using Bluetooth. For this, we needed to implement a full-duplex type connection with the RPI.

We looked for some quick solutions over the internet, but unfortunately, we found none. There were very few Bluetooth based libraries that were well written and almost none/very few had an implementation for creating Bluetooth server sockets.

That's when we decided to come up with a simple and elegant approach to our problem.

The Solution

bluetoothadapter is a package which enables a Flutter application to communicate with other devices/programs through Bluetooth. It does so using Bluetooth based server sockets, which allows the Flutter app to establish a full-duplex connection with the other Bluetooth based devices which act as its counterpart.

Features provided by bluetoothadapter

  • Setting up a UUID from the user end.
  • Checking Bluetooth connection status and giving alerts if it is off or not right.
  • Getting a list of paired devices.
  • Get a particular paired device info.
  • Start Bluetooth server.
  • Start Bluetooth client.
  • Send a message to a connected device.
  • Stream for listening to received messages.
  • Stream for listening to connection status (CONNECTED, CONNECTING, CONNECTION FAILED, LISTENING, DISCONNECTED).

Check out the code on Github - https://github.com/GeekyAnts/flutter-bluetooth-adapter

Visualization of the process

Client/Server process flow in a Bluetooth server socket
Client/Server process flow in a Bluetooth server socket

How to use ?

We start by adding the following dependency to our pubspec.yaml file:

dependencies:
  bluetoothadapter: <latest version>


There are mainly 4 main steps involved in the process:

  • Initiate the Bluetooth adapter
  • Implement listeners for observing connection status.
  • Implement listeners for receiving messages.
  • Implement methods for sending back the messages to the application counterpart.

Here's a code sample for the same:

For a full example please check out this link : https://github.com/GeekyAnts/flutter-bluetooth-adapter/tree/master/example

I hope that this solution is what you require to enable your apps to communicate through bluetooth for critical functions and this implementation will help you understand how to use bluetoothadapter.

Thanks for reading!

SHARE ON

Related Articles.

More from the engineering frontline.

Dive deep into our research and insights on design, development, and the impact of various trends to businesses.

How We Built an AI System That Automates Senior Solution Architect Workflows
Article

Apr 6, 2026

How We Built an AI System That Automates Senior Solution Architect Workflows

Discover how we built a 4-agent AI co-pilot that converts complex RFPs into draft technical proposals in 15 minutes — with built-in conflict detection, assumption surfacing, and confidence scoring.

AI Code Healer for Fixing Broken CI/CD Builds Fast
Article

Apr 6, 2026

AI Code Healer for Fixing Broken CI/CD Builds Fast

A deep dive into how GeekyAnts built an AI-powered Code Healer that analyzes CI/CD failures, summarizes logs, and generates code-level fixes to keep development moving.

A Real-Time AI Fraud Decision Engine Under 50ms
Article

Apr 2, 2026

A Real-Time AI Fraud Decision Engine Under 50ms

A deep dive into how GeekyAnts built a real-time AI fraud detection system that evaluates transactions in milliseconds using a hybrid multi-agent approach.

Building an Autonomous Multi-Agent Fraud Detection System in Under 200ms
Article

Apr 1, 2026

Building an Autonomous Multi-Agent Fraud Detection System in Under 200ms

GeekyAnts built a 5-agent fraud detection pipeline that makes decisions in under 200ms — 15x cheaper than single-model systems, with full explainability built in.

Building a Self-Healing CI/CD System with an AI Agent
Article

Mar 31, 2026

Building a Self-Healing CI/CD System with an AI Agent

When code breaks a pipeline, developers have to stop working and figure out why. This blog shows how an AI agent reads the error, finds the fix, and submits it for review all on its own.

Maestro Automation Framework — Advanced to Expert
Article

Mar 26, 2026

Maestro Automation Framework — Advanced to Expert

Master Maestro at scale. Learn architecture, reusable flows, CI/CD optimization, and how to eliminate flakiness in production-grade mobile automation.Master Maestro at scale. Learn architecture, reusable flows, CI/CD optimization, and how to eliminate flakiness in production-grade mobile automation.

Scroll for more
View all articles