flutter_system_bars 0.0.5

  • Readme
  • Changelog
  • Example
  • Installing
  • 60

flutter_system_bars (WIP) #

Flutter plugin that helps you create immersive experience for your app by defining margins based on system bars dimensions.

Screenshot

Usage #

This plugin has two main widgets:

SystemBarsInfoProvider #

This widget provides info about system bar heights and if software navigation bar is present to its descendants.

SystemBarsInfoProvider(
  builder: (context, child, systemBarsInfo, orientation) {
    return Center(
      child: Text(systemBarsInfo.navigationBarHeight, 
        textAlign: TextAlign.center, 
        style: TextStyle(color: Colors.white, fontSize: 20)
      ),
    );
  }
);

You have to pass in the builder in which you get SystemBarsInfo object and device Orientation for convenience. The child parameter is optional. You can pass child parameter to SystemBarsInfoProvider constructor and it is not affected by changes in layout.

SystemBarsInfo contains information about system bars:

class SystemBarsInfo {
  final bool hasSoftwareNavigationBar;
  final double navigationBarHeight;
  final double statusBarHeight;
}

SystemBarsMarginBox #

This widgets encapsulates SystemBarsInfoProvider and lets you choose which margins you want to show based on system bars in specified orientations.

SystemBarsMarginBox(
  portraitMargin: true,
  landscapeMargin: false,
  navigationBarMargin: true,
  statusBarMargin: true,
  child: Column(
      crossAxisAlignment: CrossAxisAlignment.stretch,
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: [
        Text('Content is below',
            textAlign: TextAlign.center,
            style: TextStyle(color: Colors.white, fontSize: 20)),
        Text('While the app occupies the entire screen.',
            textAlign: TextAlign.center,
            style: TextStyle(color: Colors.white, fontSize: 20)),
        Text('and above system bars.',
            textAlign: TextAlign.center,
            style: TextStyle(color: Colors.white, fontSize: 20)),
      ]),
);

SystemBarsMarginBox settings and their default values:

portraitMargin - default: true - specifies if margin is enabled in portrait mode

landscapeMargin - default: false - specifies if margin is enabled in landscape mode

navigationBarMargin - default: true - specifies if margin is enabled for navigation bar

statusBarMargin - default: true - specifies if margin is enabled for status bar

Disclaimer #

Plugin is currently implemented only for Android platform. On iOS it reports system bar heights as 0 and navigation bar as non existent. That is because I am a poor student who doesn´t have money for iPhone and Mac so I can't write iOS implementation. If you want to implement iOS functionality please open a pull request.

0.0.5 #

  • Added basic iOS support.

example/README.md

flutter_system_bars_example #

Demonstrates how to use the flutter_system_bars plugin.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_system_bars: ^0.0.5

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_system_bars/flutter_system_bars.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
25
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
60
Learn more about scoring.

We analyzed this package on Oct 16, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Format lib/flutter_system_bars.dart.

Run flutter format to format lib/flutter_system_bars.dart.

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test