flutter_navigation_mode 1.0.0
flutter_navigation_mode: ^1.0.0 copied to clipboard
Detect Android navigation mode (gesture, 2-button, 3-button) and navigation bar height.
import 'package:flutter/material.dart';
import 'package:flutter_navigation_mode/flutter_navigation_mode.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
NavigationModeInfo? _mode;
@override
void initState() {
super.initState();
loadNavigationMode();
}
Future<void> loadNavigationMode() async {
try {
final mode = await FlutterNavigationMode.getNavigationMode();
if (!mounted) return;
setState(() {
_mode = mode;
});
} catch (e) {
debugPrint("Error: $e");
}
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Navigation Mode Example')),
body: Center(
child: _mode == null
? const CircularProgressIndicator()
: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("Type: ${_mode!.type}"),
Text("Is Gesture: ${_mode!.isGestureNavigation}"),
Text("Height: ${_mode!.navigationBarHeight}"),
Text("Interaction Mode: ${_mode!.interactionMode}"),
],
),
),
),
);
}
}