keyboard_focus_manager 0.9.2 copy "keyboard_focus_manager: ^0.9.2" to clipboard
keyboard_focus_manager: ^0.9.2 copied to clipboard

Package for displaying pane over keyboard, especially useful for closing keyboard using FocusScope.

example/lib/main.dart

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

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Keyboard Focus Manager Example',
      theme: ThemeData(
        primaryColor: Colors.deepPurple,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  final _closeKeyboardOverlay = CloseKeyboardOverlay();

  @override
  void initState() {
    super.initState();
    _closeKeyboardOverlay.listenKeyboardVisibility(
      context,
      // OPTIONAL
      closeButtonLabel: 'CLOSE',
      closeButtonLabelStyle: TextStyle(fontSize: 15.0),
    );
  }

  @override
  void dispose() {
    _closeKeyboardOverlay.removeKeyboardVisibilityListener();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return KeyboardUnfocusArea(
      child: Scaffold(
        appBar: AppBar(
          title: Text('Keyboard Focus Manager Example'),
        ),
        body: Padding(
          padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 20.0),
          child: Column(
            children: [
              Text(
                'A pane with button which closes keyboard when tapped will be seen when TextField is in focus/tapped.',
                textAlign: TextAlign.center,
                style: TextStyle(fontSize: 16.0),
              ),
              SizedBox(height: 20.0),
              TextField(
                decoration: InputDecoration(
                  hintText: 'Ordinary TextField',
                  border: OutlineInputBorder(),
                ),
              ),
              SizedBox(height: 20.0),
              Text(
                'Keyboard will be closed when tapped anywhere outside the TextField.',
                textAlign: TextAlign.center,
                style: TextStyle(fontSize: 16.0),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
0
likes
30
pub points
0%
popularity

Publisher

unverified uploader

Package for displaying pane over keyboard, especially useful for closing keyboard using FocusScope.

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

flutter, keyboard_visibility

More

Packages that depend on keyboard_focus_manager