flutter_navigation_mode

A Flutter plugin to detect Android navigation mode (gesture, 2-button, 3-button) and retrieve navigation bar height.


✨ Features

  • Detect current navigation mode:

    • Gesture navigation
    • 2-button navigation
    • 3-button navigation
  • Get navigation bar height (in dp)

  • Works across multiple Android versions

  • Lightweight and easy to integrate


📱 Platform Support

Platform Supported
Android
iOS

🚀 Getting Started

Add the dependency in your pubspec.yaml:

dependencies:
  flutter_navigation_mode: ^1.0.0

Then run:

flutter pub get

🧠 Usage

Get full navigation mode info

import 'package:flutter_navigation_mode/flutter_navigation_mode.dart';

final mode = await FlutterNavigationMode.getNavigationMode();

print(mode.navigationType);       // NavigationType.gesture
print(mode.isGestureNavigation);  // true
print(mode.navigationBarHeight);  // e.g. 24
print(mode.interactionMode);      // e.g. 2

Get only gesture navigation status

final isGesture = await FlutterNavigationMode.isGestureNavigation();

Get navigation bar height

final height = await FlutterNavigationMode.getNavigationBarHeight();

📊 Navigation Types

enum NavigationType {
  gesture,
  threeButton,
  twoButton,
  unknown,
}

📦 Example

import 'package:flutter/material.dart';
import 'package:flutter_navigation_mode/flutter_navigation_mode.dart';

class NavigationExample extends StatefulWidget {
  const NavigationExample({super.key});

  @override
  State<NavigationExample> createState() => _NavigationExampleState();
}

class _NavigationExampleState extends State<NavigationExample> {
  NavigationModeInfo? _mode;

  @override
  void initState() {
    super.initState();
    loadMode();
  }

  Future<void> loadMode() async {
    final mode = await FlutterNavigationMode.getNavigationMode();
    setState(() => _mode = mode);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text("Navigation Mode")),
      body: Center(
        child: _mode == null
            ? const CircularProgressIndicator()
            : Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  Text("Type: ${_mode!.navigationType}"),
                  Text("Gesture: ${_mode!.isGestureNavigation}"),
                  Text("Height: ${_mode!.navigationBarHeight}"),
                ],
              ),
      ),
    );
  }
}

🤝 Contributing

Contributions are welcome!

Please follow these steps:

  1. Fork the repository
  2. Create a new branch
  3. Make your changes
  4. Submit a Pull Request

🐛 Issues

If you find a bug or have a feature request, please open an issue on GitHub.


📄 License

This project is licensed under the MIT License.