better_navbar_responsive 0.0.4 copy "better_navbar_responsive: ^0.0.4" to clipboard
better_navbar_responsive: ^0.0.4 copied to clipboard

PlatformAndroid

A flutter package to get the height occupied by the Android system UI navigation bar

better_navbar_responsive #

have you ever created a gorgeous app that works like wonders on your phone
and then someone using system UI navigationbar says "the content hides behind the navigation bar"?!
well it happened to me, so i created this to know how much space the navigation bar takes (if any)
and share it in case it might be useful for someone

Import #

import 'package:better_navbar_responsive/better_navbar_responsive.dart';

Usage #


final _betterNavbarResponsivePlugin = BetterNavbarResponsive();
navBarHeight = await _betterNavbarResponsivePlugin.getNavBarHeight();

Example #


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

import 'package:flutter/services.dart';
import 'package:better_navbar_responsive/better_navbar_responsive.dart';

void main() {
  runApp(const MyApp());
}

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  int _navBarHeight = 0;
  final _betterNavbarResponsivePlugin = BetterNavbarResponsive();

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

  Future<void> initPlatformState() async {
    int navBarHeight  = 0;

    try {
      navBarHeight = await _betterNavbarResponsivePlugin.getNavBarHeight();
      
    } on PlatformException {
      navBarHeight = 0;
    }

    if (!mounted) return;

    setState(() {
      _navBarHeight = navBarHeight;
    });
  }

  @override
  Widget build(BuildContext context) {
    final screenHeight = MediaQuery.sizeOf(context).height;
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: SizedBox(
          height: screenHeight - _navBarHeight, //bet you wont overflow now 🐩
          child: Center(
            child: Text('navBarHeight is : $_navBarHeight\n'),
          ),
        ),
      ),
    );
  }
}

2
likes
150
points
22
downloads

Publisher

verified publisherjhonaiquel.com

Weekly Downloads

A flutter package to get the height occupied by the Android system UI navigation bar

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on better_navbar_responsive

Packages that implement better_navbar_responsive