Intermediate: Integration of Huawei Ambient light awareness in flutter application(Dart)

Shiddalingeshwar M S
Huawei Developers
Published in
3 min readJul 20, 2021

In this article, we will learn Huawei Awareness Kit’s Ambient Light Awareness, It enables developers to obtain device information such as current time, location, audio device status, behaviour, ambient light awareness, weather, and nearby beacons. Ambient light sensor is a photodetector that is used to sense the amount of ambient light present, and appropriately dim the device’s screen to provide lighting effect effectively to user.

Introduction

In this article, we will learn Huawei Awareness Kit’s Ambient Light Awareness, It enables developers to obtain device information such as current time, location, audio device status, behavior, ambient light awareness, weather, and nearby beacons. Ambient light sensor is a photodetector that is used to sense the amount of ambient light present, and appropriately dim the device’s screen to provide lighting effect effectively to user.

Development Overview

You need to install Flutter and Dart plugin in IDE and I assume that you have prior knowledge about the Flutter and Dart.

Hardware Requirements

  • A computer (desktop or laptop) running Windows 10.
  • A Huawei phone with API 4.x.x or above (with the USB cable), which is used for debugging.

Software Requirements

  • Java JDK 1.7 or later.
  • Android studio software or Visual Studio or Code installed.
  • HMS Core (APK) 4.X or later.

Integration process

Step 1. Create flutter project.

Step 2. Add the App level gradle dependencies, choose inside project Android > app > build.gradle.

Add root level gradle dependencies.

Step 3: Add the below permissions in Android Manifest file.

Step 4: Add plugin path in pubspec.yaml file under dependencies.

Step 5: Create a project in AppGallery Connect.

How to initialize the barrier?

How do I set barrier?

How do I get the Light Intensity?

Result

Tricks and Tips

  • Make sure that you have downloaded latest plugin.
  • Make sure that updated plugin in yaml.
  • Make sure that plugin unzipped in parent directory of project.
  • Makes sure that agconnect-services.json file added.
  • Make sure dependencies are added in build file.
  • Run flutter pug get after adding dependencies.
  • Generating SHA-256 certificate fingerprint in android studio and configure in Ag-connect.

Conclusion

In this article, we have learnt about Huawei Awareness Kit’s Ambient Light awareness in flutter application and how to set barriers and get the light intensity in flutter application, how developer can easily integrate and get the Ambient light intensity. Ambient Light sensor provides basic lighting functionality, it improves the sense of warmth and depth of a room or space. It is a photodetector that is used to sense the amount of ambient light present, and appropriately dim the device’s screen to match it.

Thank you so much for reading, I hope this article helps you to understand the Huawei Awareness Kit’s Ambient Light awareness in flutter.

Reference

Awareness kit’s Ambient Light Awareness

Checkout in forum

--

--