simple_aws_translate 0.0.4 copy "simple_aws_translate: ^0.0.4" to clipboard
simple_aws_translate: ^0.0.4 copied to clipboard

outdated

A Simple implementation of the AWS Translation plugin.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:simple_aws_translate/simple_aws_translate.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';

  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    SimpleAwsTranslate.instance.init(
        accessKey: "your access key",
        secretKey: "your secret key");
  }

  TextEditingController textController = TextEditingController();
  String resultText = "";
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Form(
            child: Padding(
              padding: const EdgeInsets.all(8.0),
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  TextFormField(
                    controller: textController,
                    decoration: InputDecoration(labelText: "Input"),
                  ),
                  MaterialButton(
                    onPressed: () async {
                      setState(() {
                        resultText = "Translating...";
                      });
                      String? result = await SimpleAwsTranslate.instance.translateText(textController.text, to: "id");
                      if(result != null){
                        resultText = result;
                      }else{
                        resultText = "Something went wrong";
                      }
                      setState(() {
                      });
                    },
                    child: Text(
                      "Translate",
                      style: TextStyle(color: Colors.white),
                    ),
                    color: Colors.blue,
                  ),

                  Text("Translated Text: $resultText")
                ],
              ),
            ),
          ),
        ),
      ),
    );
  }
}
3
likes
0
points
5
downloads

Publisher

unverified uploader

Weekly Downloads

A Simple implementation of the AWS Translation plugin.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on simple_aws_translate

Packages that implement simple_aws_translate