sendkeyboardevent 0.1.3 copy "sendkeyboardevent: ^0.1.3" to clipboard
sendkeyboardevent: ^0.1.3 copied to clipboard

A Flutter plugin for sending keyboard events through the Android shell.

example/lib/main.dart

import 'package:flutter/material.dart';

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

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {

  DateTime timeStart;
  DateTime timeStop;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Column(
          children: <Widget>[

            TextField(
              decoration: InputDecoration(
                border: InputBorder.none,
                hintText: 'Focus on me'
              ),
              onChanged: (_) {
                setState(() {
                  timeStop = DateTime.now();
                });
              }
            ),

            SizedBox(height: 20),

            Text('Sending event took: ${(timeStart != null && timeStop != null)? (timeStart.difference(timeStop).inMilliseconds) : 'NaN'} ms'),

            SizedBox(height: 20),

            MaterialButton(
              child: Text('SEND KEYBOARD EVENT'),
              onPressed: () {
                timeStart = DateTime.now();
                SendKeyboardEvent.sendKeyboardEvent(KeyCodes.BACKSPACE);

              },
            ),

            SizedBox(height: 20),

            MaterialButton(
              child: Text('SEND TEXT'),
              onPressed: () {

                timeStart = DateTime.now();
                SendKeyboardEvent.sendKeyboardText('text');

              },
            ),

          ],
        ),
      ),
    );
  }
}
1
likes
20
pub points
0%
popularity

Publisher

unverified uploader

A Flutter plugin for sending keyboard events through the Android shell.

Repository (GitLab)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on sendkeyboardevent