Skip to content
This repository has been archived by the owner on Jan 17, 2024. It is now read-only.

Commit

Permalink
fix(AddBar): Snap over keyboard
Browse files Browse the repository at this point in the history
  • Loading branch information
moverval authored Jan 5, 2024
1 parent 683bd71 commit 1198551
Show file tree
Hide file tree
Showing 3 changed files with 207 additions and 251 deletions.
33 changes: 33 additions & 0 deletions lib/components/KeyboardSafeArea.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import 'package:flutter/material.dart';
import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart';

class KeyboardSafeArea extends StatefulWidget {
final Widget Function(BuildContext context, bool visible) builder;

const KeyboardSafeArea({super.key, required this.builder});

@override
State<KeyboardSafeArea> createState() => _KeyboardSafeAreaState();
}

class _KeyboardSafeAreaState extends State<KeyboardSafeArea> {
double _keyboardHeight = 0;
@override
void initState() {
super.initState();
}

@override
Widget build(BuildContext context) {
return KeyboardVisibilityBuilder(builder: (context, visible) {
_keyboardHeight = MediaQuery.of(context).viewInsets.bottom;

return Positioned(
left: 0,
right: 0,
height: MediaQuery.of(context).size.height - _keyboardHeight,
child: widget.builder(context, _keyboardHeight != 0),
);
});
}
}
Loading

0 comments on commit 1198551

Please sign in to comment.