How To Get Status Bar Height Using Flutter Android App

admin_img Posted By Bajarangi soft , Posted On 10-10-2020

Status bar is a horizontal graphical bar present at top of mobile application screen. Status bar is used to display important information like time, network connectivity, batter information etc. In flutter application by default the app layout starts from Status bar. So if you will starting making application without App Bar you’ll see your layout design starts just above the Status bar.

How To Get Status Bar Height Using Flutter Android App

 Get Status Bar Height 
Complete Code For  Get Status Bar Height  In Flutter
Main.dart

import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        debugShowCheckedModeBanner: false,
        home: Scaffold(
          backgroundColor: Colors.black,
            body: Center(
                child: GetStatusBarHeight()
            )
        )
    );
  }
}
class GetStatusBarHeight extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    double statusBarHeight = MediaQuery.of(context).padding.top;
    return Text('Status Bar Height = ' + statusBarHeight.toString(),
        style: TextStyle(fontSize: 25,color: Colors.white));
  }
}

Related Post