This repository has been archived by the owner on Jan 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
207 additions
and
251 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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), | ||
); | ||
}); | ||
} | ||
} |
Oops, something went wrong.