keyboard_actions 3.3.1+1
keyboard_actions: ^3.3.1+1

Flutter Android iOS web

Now you can add features to the Android / iOS keyboard in a very simple way.

example/lib/main.dart

import 'package:example/content.dart';
import 'package:flutter/material.dart';
import 'sample.dart';
import 'sample2.dart';

// Application entry-point
void main() => runApp(MyApp());

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

  _openWidget(BuildContext context, Widget widget) =>
      Navigator.of(context).push(
        MaterialPageRoute(builder: (_) => widget),
      );

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Scaffold(
        backgroundColor: Colors.amber,
        body: Builder(
          builder: (myContext) => Center(
            child: Padding(
              padding: const EdgeInsets.all(18.0),
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                crossAxisAlignment: CrossAxisAlignment.stretch,
                children: [
                  RaisedButton(
                    child: Text("Full Screen form"),
                    onPressed: () => _openWidget(
                      myContext,
                      ScaffoldTest(),
                    ),
                  ),
                  const SizedBox(
                    height: 25,
                  ),
                  RaisedButton(
                    child: Text("Dialog form"),
                    onPressed: () => _openWidget(
                      myContext,
                      DialogTest(),
                    ),
                  ),
                  const SizedBox(
                    height: 25,
                  ),
                  RaisedButton(
                    child: Text("Custom Sample 1"),
                    onPressed: () => _openWidget(
                      myContext,
                      Sample(),
                    ),
                  ),
                  const SizedBox(
                    height: 25,
                  ),
                  RaisedButton(
                    child: Text("Custom Sample 2"),
                    onPressed: () => _openWidget(
                      myContext,
                      Sample2(),
                    ),
                  )
                ],
              ),
            ),
          ),
        ),
      ),
    );
  }
}

/// Displays our [TextField]s in a [Scaffold] with a [FormKeyboardActions].
class ScaffoldTest extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Keyboard Actions Sample"),
      ),
      body: Content(),
    );
  }
}

/// Displays our [FormKeyboardActions] nested in a [AlertDialog].
class DialogTest extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Keyboard Actions Sample"),
      ),
      body: Center(
        child: FlatButton(
          color: Colors.blue,
          child: Text('Launch dialog'),
          onPressed: () => _launchInDialog(context),
        ),
      ),
    );
  }

  void _launchInDialog(BuildContext context) async {
    final height = MediaQuery.of(context).size.height / 3;
    await showDialog(
      context: context,
      builder: (context) {
        return AlertDialog(
          title: Text('Dialog test'),
          content: SizedBox(
            height: height,
            child: Content(
              isDialog: true,
            ),
          ),
          actions: [
            FlatButton(
              child: Text('Ok'),
              onPressed: () {
                Navigator.of(context).pop();
              },
            ),
          ],
        );
      },
    );
  }
}
215
likes
110
pub points
96%
popularity

Publisher

diegoveloper.com

Now you can add features to the Android / iOS keyboard in a very simple way.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on keyboard_actions