fbpx

Use of “Services.dart” Package in the Flutter

We often come at a point where we need some flexibility, in our app UI. so in this blog, I want to share two of the helpful features of Services package in flutter. So let’s start with it.

Use of “Services.dart” Package in the Flutter 1

First: Block the landScape Mode.

So Some times we don’t need our app to work in LandScape mode but we need to tell it to our system.

Dev:  “Hey stop!!! I don’t want my app to work in landscape mode.”

Flutter: “okay!! then use Services.dart package.”

Use of “Services.dart” Package in the Flutter 2

But first, you need to just Import the package:

import 'package:flutter/services.dart';

After importing its time to use features of this package. 

@override
 Widget build(BuildContext context) {
 
   SystemChrome.setPreferredOrientations([
     DeviceOrientation.portraitUp,
     DeviceOrientation.portraitDown,
   ]);

So in the code, above we just only allowed the orientation of the app to work in Portrait mode.

Second: sytemUIOverlayStyle Custom (StatusBar / NavigationBar)

Use of “Services.dart” Package in the Flutter 3

So sometimes you need your App UI to be in your control But StatusBar and NavigationBar have their own Attitude. So to teach them a lesson we can use this simple code to work things out.

@override
 Widget build(BuildContext context) {
   
   SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
     statusBarColor: Color(0xff59AEAC),
     statusBarIconBrightness: Brightness.dark,
     systemNavigationBarColor: Color(0xff59AEAC),
     systemNavigationBarIconBrightness: Brightness.dark,
   ));

In this one, I just played around with the background colour and the icon Colour of the StatusBar and NavigationBar.

So That’s Some of the good features you can use to make your Flutter experience efficient.

Hot Topics

JSON Parsing in Android Tutorial

In this article, we will learn, how to do JSON Parsing in Android. JSON stands for JavaScript Object Notation. It is a lightweight format...

How to get Partner Title in PUBG Mobile in 5 minutes?

This is the new title that PUBG Mobile has introduced in October 2019 update. The title name is "Partner". What is Partner Title in PUBG Mobile? This...

Google Login And Registration For Android Using Firebase Authentication

In this tutorial, we will learn how to build simple google login and registration for android using Firebase Authentication. We have added Email &...

Related Articles

Navigating Through Screens with Named Routes

An app is nothing but just lots of beautiful screens with different functionalities connected together for great and easy user experience. Let us dive...

Social Media Buttons in Flutter Web

Social media buttons on websites are not a new thing. We all are familiar with them somehow. We can find it on every website...

Animated Navigation-Bar in Flutter

The Burger-Menu is kind of outdated now. we all can observe that It’s all about Navigation-bars. Time to see how flutter let us play...