flutter_translate_kit 0.0.3 copy "flutter_translate_kit: ^0.0.3" to clipboard
flutter_translate_kit: ^0.0.3 copied to clipboard

A complete Flutter localization toolkit — zero config, offline-first, on-device ML translation with a built-in CLI that auto-wraps your entire app. No API keys. No .arb files. Works out of the box.

flutter_translate_kit 🌍 #

pub.dev License: MIT Platform

The only Flutter localization package you'll ever need.

✅ No API keys  |  ✅ Works offline  |  ✅ 50+ languages  |  ✅ CLI auto-wraps your entire app  |  ✅ RTL auto-support


Why flutter_translate_kit? #

Feature Other packages flutter_translate_kit
No API key needed ❌ Requires key ✅ Never needed
Works offline ✅ On-device ML
CLI auto-wrap ✅ One command
RTL auto-detect ✅ Built-in
Smart caching ✅ Hive-powered
No .arb files ❌ Required ✅ Never needed

Quick Start #

1. Install #

# pubspec.yaml
dependencies:
  flutter_translate_kit: ^0.0.1

2. Initialize in main.dart #

import 'package:flutter_translate_kit/flutter_translate_kit.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await TranslationService().init(
    targetLanguage: TranslateLanguage.hindi, // 👈 Set your language
  );

  runApp(const MyApp());
}

3. Wrap your MaterialApp and add the language-change overlay #

Use KitLanguageChangeOverlay so users see a loading screen until all text has updated after switching language (avoids half-translated UI):

import 'package:flutter_translate_kit/flutter_translate_kit.dart';

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return KitScope(
      builder: (locale, delegates) => MaterialApp(
        locale: locale,
        localizationsDelegates: delegates,
        supportedLocales: KitScope.supportedLocales,
        home: KitLanguageChangeOverlay(
          child: HomeScreen(),
        ),
      ),
    );
  }
}

4. Use KitText instead of Text #

// Before
Text('Welcome to the app')

// After
KitText('Welcome to the app')   // auto-translates to Hindi ✅

CLI — Auto-wrap your entire project #

For large existing apps, use the CLI to automatically replace every Text() with KitText():

# Install globally (after publishing to pub.dev)
dart pub global activate flutter_translate_kit

# Or activate locally during development
dart pub global activate --source path .

# Preview what will change (no files touched)
ftk wrap --dry-run

# Apply to all files
ftk wrap

# Check your coverage
ftk stats

# Undo if needed
ftk restore

Before:

Text('Welcome')
Text('Settings', style: TextStyle(fontSize: 16))
Text(myVariable)

After (auto-generated):

KitText('Welcome')
KitText('Settings', style: TextStyle(fontSize: 16))
KitText(myVariable)

Features #

Switch Language at Runtime #

// Switch to any of 50+ languages instantly
await TranslationService().setLanguage(TranslateLanguage.arabic);
await TranslationService().setLanguage(TranslateLanguage.french);
await TranslationService().setLanguageByCode('de'); // by BCP-47 code

Language preference is persisted — survives app restarts automatically.

Loading overlay when changing language #

Wrap your app content with KitLanguageChangeOverlay (see Quick Start step 3). When the user switches language, a full-screen loading overlay is shown until all KitText widgets have updated, so the app never shows a mix of old and new language. You can customize the duration:

TranslationService.languageChangeLoadingDuration = Duration(milliseconds: 2000); // default: 1500

Built-in Language Switcher UI #

KitLanguageSwitcher(
  languages: [
    TranslateLanguage.english,
    TranslateLanguage.hindi,
    TranslateLanguage.arabic,
    TranslateLanguage.french,
  ],
  onChanged: (lang) => print('Changed to ${lang.displayName}'),
)

Model Download with Progress #

KitModelDownloadButton(
  language: TranslateLanguage.hindi,
  onDownloaded: () => print('Hindi model ready!'),
)

String Extension #

final translated = await 'Hello World'.kit;

RTL Auto-Detection #

When you switch to Arabic, Urdu, Hebrew, or Persian — the entire app layout flips to RTL automatically. No extra code needed.

Smart Translation Cache #

Translated strings are cached in Hive. The same string is never translated twice, making subsequent launches near-instant.

print(TranslationService().cacheSize); // number of cached strings
await TranslationService().clearCache(); // reset if needed

Opt out of translation #

KitText('API_KEY_abc123', translate: false) // never translated

Supported Languages (50+) #

Hindi, Arabic, French, Spanish, German, Chinese, Japanese, Korean, Portuguese, Russian, Italian, Dutch, Polish, Turkish, Ukrainian, Thai, Vietnamese, Indonesian, Malay, Bengali, Gujarati, Marathi, Tamil, Telugu, Kannada, Urdu, Persian, Hebrew, and more.


Platform Requirements #

Platform Supported
Android ✅ (API 21+)
iOS ✅ (iOS 15.5+)
Web ❌ (ML Kit is mobile-only)
Desktop

Android setup #

No additional setup required.

iOS setup #

In ios/Podfile:

platform :ios, '15.5'

Simulator note (Xcode 26+): Google ML Kit's native iOS frameworks don't yet include arm64-simulator slices, so building for the iOS Simulator is not supported. Test on a real device or use an Android emulator. Alternatively, use a Rosetta simulator destination in Xcode.


License #

MIT © 2026 — Built with ❤️ using Google ML Kit

1
likes
0
points
217
downloads

Publisher

unverified uploader

Weekly Downloads

A complete Flutter localization toolkit — zero config, offline-first, on-device ML translation with a built-in CLI that auto-wraps your entire app. No API keys. No .arb files. Works out of the box.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, flutter_localizations, google_mlkit_translation, hive, hive_flutter, intl, path, rxdart

More

Packages that depend on flutter_translate_kit