auto_translate_plugin 1.0.2
auto_translate_plugin: ^1.0.2 copied to clipboard
A premium Flutter plugin for seamless on-device text translation using Google ML Kit. Offline, privacy-first, and easy to integrate.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:auto_translate_plugin/auto_translate_plugin.dart';
void main() {
runApp(
ChangeNotifierProvider(
create: (_) => TranslatorProvider(),
child: const MyApp(),
),
);
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: const HomeScreen(),
);
}
}
class HomeScreen extends StatelessWidget {
const HomeScreen({super.key});
@override
Widget build(BuildContext context) {
final translator = context.read<TranslatorProvider>();
return Scaffold(
appBar: AppBar(
title: const AutoTranslateText(
"Auto Translate Demo",
style: TextStyle(color: Colors.white),
),
backgroundColor: Colors.blue,
),
body: Padding(
padding: const EdgeInsets.all(20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const AutoTranslateText(
"Welcome to my application",
style: TextStyle(fontSize: 22),
),
const SizedBox(height: 10),
const AutoTranslateText(
"This app translates text automatically",
),
const SizedBox(height: 30),
const AutoTranslateText(
"Select Language",
style: TextStyle(fontWeight: FontWeight.bold),
),
const SizedBox(height: 10),
Row(
children: [
ElevatedButton(
onPressed: () => translator.changeLanguage('en'),
child: const Text("English"),
),
const SizedBox(width: 10),
ElevatedButton(
onPressed: () => translator.changeLanguage('ta'),
child: const Text("Tamil"),
),
const SizedBox(width: 10),
ElevatedButton(
onPressed: () => translator.changeLanguage('hi'),
child: const Text("Hindi"),
),
],
),
],
),
),
);
}
}