PersistentSafeAreaBottom class final
Provides access to the system's bottom safe area (home indicator or navigation bar).
This class exposes a ValueNotifier that tracks the current bottom safe area height — typically the system UI padding at the bottom of the screen, such as:
- the home indicator on iOS, or
- the navigation bar on Android.
The bottom inset value remains stable during keyboard animations and updates only when the system layout changes (for example, due to orientation or navigation mode changes).
Example
import 'package:keyboard_insets/keyboard_insets.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
// Begin observing the native safe area changes.
PersistentSafeAreaBottom.startObserving();
}
@override
void dispose() {
// Stop observing when the widget is removed from the tree.
PersistentSafeAreaBottom.stopObserving();
super.dispose();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: ValueListenableBuilder<double>(
valueListenable: PersistentSafeAreaBottom.notifier!,
builder: (context, bottomInset, _) {
return Padding(
padding: EdgeInsets.only(bottom: bottomInset),
child: Center(
child: Text('Bottom safe area: $bottomInset'),
),
);
},
),
),
);
}
}
Lifecycle
- You only can manually manage observation lifecycle by calling startObserving and stopObserving.
See also
- PersistentSafeArea, a widget that applies the bottom safe area padding to its child and keeps it stable during keyboard animations.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
-
notifier
→ ValueNotifier<
double> ? -
A ValueNotifier representing the current bottom safe area height in logical pixels.
no setter
Static Methods
-
startObserving(
) → void - Starts observing system safe area changes.
-
stopObserving(
) → void - Stops observing system safe area changes.