Notification service for keyboard visibility. This is a fork, original project here.
Add the dependency to your pubspec.yaml
dependencies:
flutter_keyboard_visibility: ^0.7.0
(Please note that the two spaces in the beginning of the line are important)
Run flutter packages get
in your root folder after saving the pubspec.yaml file.
Import package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart
The best practice to call the addNewListener function is inside the initState function as in the following example:
import 'package:keyboard_visibility/keyboard_visibility.dart';
@override
void initState() {
super.initState();
KeyboardVisibilityNotification().addNewListener(
onChange: (bool visible) {
print(visible);
},
);
}