TypeMate: Building a System-Wide Writing Assistant for Flutter on Android

Sometimes the simplest ideas solve the biggest headaches.

I wanted a way to trigger a writing assistant overlay whenever a user taps on a text field in any app. Simple to describe. Surprisingly tricky to build β€” especially in Flutter.

This blog is about how that problem led to TypeMate, a Flutter plugin that lets you create system-wide overlays on Android.

πŸ’‘ The Problem

Most writing tools live inside one app β€” think Grammarly, Google Docs, Notion.
But what if you want:

  • Grammar check in your messaging app

  • AI suggestions in your email app

  • Quick text snippets for any form

On Android, it’s technically possible with Accessibility Service + Overlay, but Flutter didn’t have a clean solution.

πŸ›  The Approach

The concept:

User taps a text field in any app
        ↓
Accessibility Service detects focus
        ↓
Overlay bubble appears on top
        ↓
User interacts with writing assistant tools

πŸ“¦ What TypeMate Does

TypeMate combines three components:

1. Flutter Plugin Interface

The Dart API that developers call:

await TypeMate.instance.initialize();
await TypeMate.instance.startOverlayService();

2. Android Accessibility Service

Detects when a TYPE_VIEW_FOCUSED event happens in any app.

3. Overlay Service

Shows a draggable, customizable bubble using SYSTEM_ALERT_WINDOW.

βš™οΈ Key Features

  • System-wide overlay detection

  • Customizable bubble UI

  • Runs in the background as a Foreground Service

  • Permission handling (Overlay + Accessibility)

πŸ” The Technical Challenges

  1. Permission Flow
  • Android requires manual enabling of both the Overlay & Accessibility Service.

  • TypeMate provides methods to open these settings easily.

2. Battery Optimisation

  • Foreground Service is needed to avoid the system killing it.

3. Cross-App Event Handling

  • Accessibility events are noisy β€” filtering only text field focus events was key.

πŸš€ Use Cases

  • AI Writing Assistant

  • Connect to GPT or other NLP tools to improve writing in real-time.

  • Grammar & Spell Check

  • Like Grammarly, but integrated into any text field.

  • Quick Insert Tools

  • Add snippets, templates, or frequently used phrases anywhere.

  • Custom Productivity Tools

  • Translate text, expand shorthand, etc.

πŸ“Œ Example Usage

TypeMate.instance.textFieldFocusedStream.listen((_) {
  print("Text field focused in an external app");
  // Show your custom tools
});

🚦 Limitations

  • Android only (iOS blocks system-wide overlays)

  • Manual permission steps required

  • API Level 21+ needed for overlay features

πŸ’¬ Closing Thoughts

TypeMate is just starting.
Planned features:

  • Custom bubble UI builder in Flutter

  • Better performance & event filtering

  • Integration-ready hooks for AI/NLP tools

I’d love the community to try it, break it, and improve it.

πŸ“¦ Pub.dev: TypeMate
πŸ’» GitHub: Repository

0
Subscribe to my newsletter

Read articles from Ratul Hasan Ruhan directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Ratul Hasan Ruhan
Ratul Hasan Ruhan

Hey, I'm Ratul Hasan Ruhanβ€”a Flutter enthusiast, mobile app developer, and tech blogger. Let's explore the world of Flutter together! πŸš€ #MobileDev