DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
Mountain View desk5 min

How to Build a Flutter App That Translates Text Without the Google Translate API

Flutter can translate arbitrary text without the Google Translate API using on-device ML Kit or an HTTP service such as LibreTranslate. Here’s how to choose and implement each approach.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

You can translate text in a Flutter app without calling the Google Translate API. For Android and iOS apps that need offline translation, use on-device ML Kit through the community-maintained google_mlkit_translation plugin. For a non-Google engine or centrally managed translation, send text to a service such as LibreTranslate. Flutter’s own internationalization tools are for translating your app interface; they do not translate arbitrary text entered by users.

Choose between on-device translation and a translation service

The right approach depends on your target platforms, offline requirements, acceptable translation quality, and how you want text handled.

As an Amazon Associate I earn from qualifying purchases.

Decision point On-device ML Kit LibreTranslate API
Network After language models are downloaded, translation can run without sending text to a remote translation server. Google ML Kit Requires a reachable self-hosted or managed HTTP service. LibreTranslate
Flutter platforms The Flutter plugin documents Android and iOS, not web. Plugin documentation Can be called from Flutter platforms that can reach the service, subject to network, deployment, and CORS configuration.
Operations Download and manage language models on the device. Plugin documentation Run your own service or depend on a managed host. LibreTranslate
Language support and quality Google documents more than 50 languages and describes the feature as intended for casual, simple translation. Quality varies by language pair; non-English pairs use English as an intermediate language. Google ML Kit Supported languages Check the installed language packages and test your content on the chosen deployment; availability and quality depend on that instance.
Text handling Translation text need not be sent to a remote server for translation. Other app services, such as analytics or crash reporting, have separate data flows. Google ML Kit Text is submitted to the translation endpoint. Review the selected host’s data practices and terms. API documentation
Attribution and restrictions Follow applicable Google attribution and branding guidance; ML Kit translation is restricted on embedded devices without prior permission. ML Kit terms Review the project and hosting terms for the deployment you choose.

Build an offline-capable app with ML Kit

1. Check platform and language requirements

ML Kit on-device translation is a practical fit when you are building for Android or iOS, your language pairs are supported, and casual translation quality is sufficient. Google’s current documentation lists more than 50 languages; check its supported-language table rather than assuming every Flutter locale is available. The table uses language codes such as en, es, fr, ja, and zh. View supported languages

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The plugin documentation lists iOS deployment target 15.5 or newer, Xcode 15.3 or newer, and Android minSdkVersion 21, targetSdkVersion 35, and compileSdkVersion 35. These are package-page requirements and may change, so verify them against the current plugin documentation when setting up your project. google_mlkit_translation on pub.dev

2. Add the plugin and map language choices

Add the current google_mlkit_translation dependency from pub.dev. Map the languages selected in your app to the plugin’s supported TranslateLanguage values and corresponding language codes. Do not assume an arbitrary locale tag is accepted just because Flutter can represent it.

This plugin is a community-maintained bridge from Dart to Google’s native iOS and Android ML Kit APIs; it is not sponsored or maintained by Google. Its documented platform support does not include Flutter web. When debugging, account for native project setup as well as Dart code. Plugin documentation

3. Download both language models

Tell users when a language model needs to be prepared. Before translating, check that both the source and target models are downloaded; download missing models and show the user the preparation state. The plugin provides model-manager methods to check, download, and delete models. Account for download failures and users who are offline before setup is complete. Plugin documentation

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

4. Translate asynchronously and clean up

Create an OnDeviceTranslator with the selected source and target languages, call translateText, and close the translator when the screen or service no longer needs it. Keep the interface responsive and handle empty input, repeated requests, models that are not ready, and lifecycle changes in your app.

final manager = OnDeviceTranslatorModelManager();
await manager.downloadModel(sourceLanguage.bcpCode);
await manager.downloadModel(targetLanguage.bcpCode);

final translator = OnDeviceTranslator(
  sourceLanguage: sourceLanguage,
  targetLanguage: targetLanguage,
);
try {
  final translated = await translator.translateText(inputText);
  // Render translated text in the UI.
} finally {
  translator.close();
}

This is a conceptual flow, not a tested, drop-in app. Confirm imports, package version, enum names, model readiness checks, and error handling against the plugin’s current API before using it in a release. Plugin documentation

5. Set expectations about accuracy and data

Google says on-device translation is intended for casual and simple translations. Language-pair quality can vary, and non-English-to-non-English translation uses English as an intermediate language. Test the actual pairs and content your app will handle; do not rely on this route for high-stakes translation without an appropriate evaluation and safeguards. Google ML Kit

On-device processing means the translation text does not need to go to a remote translation server. It does not establish that every part of your app is private: analytics, crash reporting, backups, and other services may handle data separately.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Use LibreTranslate when you need an HTTP translation service

LibreTranslate is open-source machine translation software powered by Argos Translate. It documents both self-hosting and managed hosting. With self-hosting, you control the deployment; with managed hosting, you rely on a third party. The appropriate choice depends on your operations capacity and the deployment’s terms, availability, and data handling. LibreTranslate

Call the documented translation endpoint

LibreTranslate documents a POST /translate endpoint. Its required inputs are text in q, a source language code (or auto), and a target code. Optional fields include format (text or html), alternatives, and api_key. A successful response includes translatedText. Documented errors include 400 for an invalid request, 403 for a banned request, 429 for rate limiting, and 500 for a translation error. API documentation

{
  "q": "Hello world!",
  "source": "en",
  "target": "es",
  "format": "text"
}

Keep private credentials off the device

If your chosen managed endpoint requires a private API key, do not put that key in the Flutter app: a key shipped to users can be extracted. A common production design is Flutter app → your backend → translation service. A backend can keep credentials server-side and apply rate limits, abuse controls, logging policies, or provider switching. This is an architectural recommendation, not a LibreTranslate requirement.

A direct app-to-endpoint request may be appropriate for a service designed for public access, but first check its authentication rules and network configuration. Before choosing a managed provider, assess language coverage, translation quality for your content, data retention, authentication, request limits, costs, latency, uptime commitments, and fallback options. Those terms vary by provider and deployment.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Know when Flutter localization is the right tool

Flutter internationalization and localization support is for translating the app’s own interface: labels, buttons, messages, and other UI content. Use that when you are preparing a multilingual product interface. It does not, by itself, translate arbitrary user-entered text at runtime; that requires a translation engine such as on-device ML Kit or a translation service. Flutter internationalization documentation

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.