Skip to content

A plugin to get the SafeArea size using platform channels, making it easy to design around SafeArea's limitations.

License

Notifications You must be signed in to change notification settings

StepFischer/safe_area_size

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Safe Area Size

A plugin to get the SafeArea size using platform channels, making it easy to design around SafeArea's limitations.

Why?

The way SafeArea is designed, if you insert it into your root structure, you no longer have access to changes of MediaQuery Insets or Padding.

So I've made this plugin to work around this limitation, allowing access to these values anyway.

How?

Make it a dependency inside your application:

dependencies:
  safe_area_size: 0.1.0

Import it:

import 'package:safe_area_size/safe_area_size.dart';

Make one async method inside your widget that makes use of the included platform channel calls:

Future<void> initPlatformState() async {
    int navigationBarHeight;
    int statusBarHeigth;
    
    try {
      statusBarHeigth = await SafeAreaSize.statusBarSize;
      navigationBarHeight = await SafeAreaSize.navigationBarSize;
    } on PlatformException {
      statusBarHeigth = 0;
      navigationBarHeight = 0;
    }
    
    if (!mounted) return;

    setState(() {
      _statusBarHeight = statusBarHeigth;
      _navigationBarHeight = navigationBarHeight;
    });
  }

You're done!

TODO

  • Android version
  • iOS version

About

A plugin to get the SafeArea size using platform channels, making it easy to design around SafeArea's limitations.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Dart 50.3%
  • Kotlin 26.4%
  • Swift 9.1%
  • Ruby 6.4%
  • Shell 4.0%
  • Objective-C 3.8%